git生成SSH KEY並添加到Github

  1. 進入C:\Users\****\.ssh刪除原本的ssh key
  2. 執行:ssh-keygen -t rsa -C "[email protected]  然後連續回車3次生成key
  3. 添加key  執行:eval $(ssh-agent -s)      再執行:ssh-add ~/.ssh/id_rsa
  4. 把key複製到剪貼板  win:clip < ~/.ssh/id_rsa.pub  mac:pbcopy < ~/.ssh/id_rsa.pub
  5. 到github添加一個SSH KEY
  6. 連接測試,執行:ssh -T [email protected]
         ssh -T [email protected]
     如果出現:ssh: connect to host github.com port 22: Connection timed out
     在.ssh文件夾裏新建一個config文件:
 
       Host github.com
      User Github用戶名
      Hostname ssh.github.com
      PreferredAuthentications publickey
      IdentityFile ~/.ssh/id_rsa
      Port 443
 
(User爲Github用戶名)
 

    7.再執行:ssh -T [email protected]

  輸入yes回車,即可訪問
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章