为Github帐号添加SSH keys
#一、创建SSH key1
2
3
4$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/you/.ssh/id_rsa):
然后系统提示输入文件保存位置等信息,按提示填写回车1
2
3
4
5
6
7
8
9
10
11
12Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]
Your identification has been saved in /home/you/.ssh/id_rsa.
# Your public key has been saved in /home/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
# Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
生成的SSH key文件保存在中~/.ssh/id_rsa.pub
文本编辑工具打开该文件:1
$ gedit ~/.ssh/id_rsa.pub
接着拷贝.ssh/id_rsa.pub文件内的所有内容,将它粘帖到github帐号管理中的添加SSH key界面中。
#二、打开github帐号管理中的添加SSH key,步骤如下
登录github
点击右上方的Accounting settings图标
选择 SSH key
点击 Add SSH key
在出现的界面中填写SSH key的名称,填一个你自己喜欢的名称即可,然后将上面拷贝的~/.ssh/id_rsa.pub文件内容粘帖到key一栏,在点击“add key”按钮就可以了。
添加过程github会提示你输入一次你的github密码
添加完成后再次执行git clone就可以成功克隆github上的代码库了。
参考来源:
https://help.github.com/articles/generating-ssh-keys/#platform-linux
http://blog.csdn.net/keyboardota/article/details/7603630
原文作者: ghbhaha
原文链接: /2015/01/20/为Github帐号添加SSH-keys/
版权声明: 转载请注明出处(必须保留作者署名及链接)