SSH key提供了一种与GitHub通讯的方式,经过这种方式,可以在不输入密码的状况下,将GitHub做为本身的remote端服务器,进行版本控制前端
输入下面的命令,若是有文件id_rsa.pub
或 id_dsa.pub
,则直接进入步骤3将SSH key添加到GitHub中,不然进入第二步生成SSH keygit
ls -al ~/.ssh
复制代码
以下图就表示存在,能够直接跳入第三步:github
ssh-keygen -t rsa -C "your_email@example.com"
默认会在相应路径下(/your_home_path)
生成id_rsa
和id_rsa.pub
两个文件,以下面代码所示web
ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key using the provided email
Generating public/private rsa key pair.
Enter file in which to save the key (/your_home_path/.ssh/id_rsa):
复制代码
设置passphrase后,进行版本控制时,每次与GitHub通讯都会要求输入passphrase,以免某些“失误”segmentfault
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
复制代码
sample result:bash
Your identification has been saved in /your_home_path/.ssh/id_rsa.
Your public key has been saved in /your_home_path/.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
复制代码
用本身喜欢的文本编辑器打开id_rsa.pub
文件,里面的信息即为SSH key
,将这些信息复制到GitHub的Add SSH key
页面便可服务器
不一样的操做系统,均有一些命令,直接将SSH key从文件拷贝到粘贴板中,以下:ssh
pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
复制代码
clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
复制代码
sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
复制代码
复制上面的key后粘贴到github new key便可,以下图:编辑器
若是你们有兴趣,欢迎关注公众号:_facebook(web技术进阶),查看更多优质文章,欢迎你们加入个人前端交流群:866068198 ,一块儿交流学习前端技术。博主目前一直在自学Node中,技术有限,若是能够,会尽力给你们提供一些帮助,或是一些学习方法.ide
有须要刷钻,刷会员,刷腾讯视频会员,涨粉丝等等相关意向的小伙伴们,能够访问做者推荐的超值代刷网站:qq.usword.cn, 也能够扫描下方二维码
If you have some questions after you see this article, you can contact me or you can find some info by clicking these links.