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.