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回车,即可访问
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章