使用ssh远程访问github

使用环境

window7系统

环境

git软件(携带的bash终端类似linux的终端很好用建议安装)
有一个可用的github账号

1. 先生成需要的PUBLIC KEY

打开bash软件执行如下命令

ssh-keygen -t rsa 指定生成key的路径名称,一路回车即可

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/lenovo/.ssh/id_rsa): /c/Users/lenovo/.ssh/id_rsa_github_hexo
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/lenovo/.ssh/id_rsa.
Your public key has been saved in /c/Users/lenovo/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ULsfGWCKY1aJqFQ24QkUxuPu3TiBqoJHXy6mHpQ/i0k lenovo@lenovo-PC
The key's randomart image is:
+---[RSA 2048]----+
|o=o*....+        |
|.+= +o.+ o       |
|o..o= o . .      |
|.. + . . . o     |
|. +     S o      |
| +.o  .  . .     |
|+.E.*o    .      |
|+o.B++.          |
|+o=oo.           |
+----[SHA256]-----+

这样我们就在~/.ssh路径下生成两个文件id_rsaid_rsa.pub

$ ll ~/.ssh
total 15
-rw-r--r-- 1 lenovo 197121  114 九月   19 14:32 config
-rw-r--r-- 1 lenovo 197121 1679 九月   17 14:58 id_rsa
-rw-r--r-- 1 lenovo 197121  398 九月   17 14:58 id_rsa.pub

2. 打开github的 ssh 管理页面把 对应的公钥提交保存到代码管理服务器 (.pub 结尾)

在终端执行

cat id_rsa.pub

github具体位置在 点击账户的Settings中的SSH and FPG keys 点击New SSH key绿色按钮 输入自己本地id_rsa_github_hexo.pub中的内容

3. 测试配置完毕后是否可以ssh访问github

$ ssh -T git@github.com
Hi qnyt1993! You've successfully authenticated, but GitHub does not provide shell access.

这里表明已经可以了,配置结束

原文地址:https://www.cnblogs.com/ifme/p/11549790.html