windows git ssh key for github

來源:互聯網
上載者:User

標籤:blog   http   io   os   ar   strong   for   檔案   2014   

第一:檢查.ssh是否存在(ls -al ~/.ssh)
$ ls -al ~/.sshLists the files in your .ssh directory, if they exist

第二:產生新的SSH key(ssh-keygen -t rsa -C "[email protected]")

$ ssh-keygen -t rsa -C "[email protected]"Creates a new ssh key, using the provided email as a labelGenerating public/private rsa key pair.Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase][Press enter]
Enter same passphrase again: [Type passphrase again][Press enter]
產生的結果如下:
Your identification has been saved in /c/Users/you/.ssh/id_rsa.Your public key has been saved in /c/Users/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 [email protected]

添加新的key到ssh-agent:
$ ssh-agent -sAgent pid 59566$ ssh-add ~/.ssh/id_rsa

如果出現Could not open a connection to your authentication agent
解決辦法:
$ eval $(ssh-agent)
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
Identity added:/c/Users/you/.ssh/id_rsa(/c/Users/you/.ssh/id_rsa) 
第三:添加ssh key到github中
$ clip < ~/.ssh/id_rsa.pubCopies the contents of the id_rsa.pub file to your clipboard
如所示:

第四:檢查如否配置成功

在Git Bash中輸入:

$ ssh -T [email protected]Attempts to ssh to github

或許會出現:

The authenticity of host ‘github.com (207.97.227.239)‘ can‘t 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)?

這是正常的,輸入yes即可

Hi username! You‘ve successfully authenticated, but GitHub does notprovide shell access.
第五:改變git的remote url:將https://github.com/xxxx.git改成[email protected]:xxxx.git

即修改.git/config檔案

 

文章摘自:https://help.github.com/articles/generating-ssh-keys

 

windows git ssh key for github

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.