码迷,mamicode.com
首页 > Windows程序 > 详细

Windows客户端配置GitHub的SSH公钥

时间:2017-09-08 22:47:54      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:-o   lan   permanent   点击   编辑   ssh公钥   href   tar   rsa   

检查SSH keys的设置

$ cd ~/.ssh/

如果显示”No such file or directory”,跳到第三步,否则继续。

备份和移除原来的SSH key设置

如果已经存在key文件,需要备份该数据并删除之

$ ls
id_rsa  id_rsa.pub  known_hosts
$ mkdir key_backup
$ cp id_rsa* key_backup/
$ rm id_rsa*

生成新的SSH key

输入下面的代码,可以生成新的key文件,只需要使用默认的设置即可,当需要输入文件名的时候,回车即可

$ ssh-keygen -t rsa -C "你的邮箱@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/WX/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/WX/.ssh/id_rsa.
Your public key has been saved in /c/Users/WX/.ssh/id_rsa.pub.
The key fingerprint is:
1d:cc:7e:b3:7e:92:f7:ab:c6:75:56:73:62:30:bc:8c 你的邮箱@qq.com
The keys randomart image is:
+--[ RSA 2048]----+
|           .     |
|         o  +    |
|          +o +   |
|         oE.o o.o|
|        S o o. .+|
|           . o .o|
|            o....|
|           .ooo  |
|            o=.oo|
+-----------------+
Enter passphrase (empty for no passphrase):这里可以输入密码,在登录时验证

添加SSH key到GitHub

用文本编辑工具打开id_rsa.pub文件,如果看不到这个文件,你需要设置显示隐藏文件。准确的复制这个文件的内容,才能保证设置的成功。
在GitHub的主页上点击设置按钮,选择SSH Keys项,把复制的内容粘贴进去,然后点击Add Key按钮即可,Title任意选择。

测试一下

输入下面命令,测试是否设置成功(第一次登录)

$ ssh -T git@github.com
The authenticity of host github.com (192.30.255.112) cant be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? y
Warning: Permanently added github.com,192.30.255.112 (RSA) to the list of know
n hosts.
Enter passphrase for key /c/Users/dyf/.ssh/id_rsa:(如果上一步设置密码 这里需要输入)
Hi dyf007! Youve successfully authenticated, but GitHub does not provide shell
access.

参考:http://codepub.cn/2015/06/02/Windows-client-configuration-of-SSH-public-key-on-GitHub/    (这里有设置多个sshKey的说明)

Windows客户端配置GitHub的SSH公钥

标签:-o   lan   permanent   点击   编辑   ssh公钥   href   tar   rsa   

原文地址:http://www.cnblogs.com/soul-mate/p/7496509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!