一、生成SSH密钥过程:
1.查看本地是否已经有了ssh密钥:cd ~/.ssh
ls
如果没有密钥则不会有文件夹,有则备份删除
2.生成密钥:
$ssh-keygen -t rsa -C “1587272615@qq.com”
Your identification has been saved in /home/tekkub/.ssh/id_rsa.
Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
………………这是密钥
Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
………………这是密钥
之后根据提示连续回车就可在~/.ssh目录下得到id_rsa和id_rsa.pub两个文件,id_rsa.pub里存放的是我们要在git网站上添加的公钥key.
3.添加密钥到ssh:
ssh-add 文件名(如~/.ssh) 切记必须把密钥添加到ssh,否则之后在git上添加ssh公钥,会显示该公钥Never used。
4.在github上添加ssh公钥即:
在终端:cat id_rsa.pub查看公钥:
复制并登陆
https://github.com,添加ssh。
5.测试:ssh git@github.com
Hi wangxaioli! You've successfully authenticated, but GitHub does not provide shell access.
则表示已经成功把公钥添加到git上。