git配置ssh免密登錄


配置ssh

  • 1.輸入命令:cd ~/.ssh 然后輸入: $ ls 會看到以下內容:authorized_keys2 id_dsa known_hosts config id_dsa.pub 如圖:

  • 2.如果沒有.ssh文件,這個時候你就要輸入命令:$ ssh-keygen -t rsa -C "email@email.com" 來創建.ssh,
  • 3.然后你就會看到:Creates a new ssh key using the provided email # Generating public/private rsa key pair.

Enter file in which to save the key (/home/you/.ssh/id_rsa):直接一路enter就可以
Enter same passphrase again: [Type passphrase again]會所提示你輸入自己密碼輸不輸都可以

  • 4.完了之后會出現:Your public key has been saved in /home/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 your_email@youremail.com這時候就完成了

添加公鑰到你的get

  • 1.查看你生成的公鑰:$ cat ~/.ssh/id_rsa.pub
  • 2.你就可以看到自己生成的公鑰了如圖:

  • 3.登陸你的github帳戶。點擊你的頭像,然后 Settings -> 左欄點擊 SSH and GPG keys -> 點擊 New SSH key新建公鑰title可以隨便輸key就是你剛剛新建的公鑰
  • 4.可以測試下:ssh git@github.com如果輸出Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access. Connection to github.com closed.說明成功了如圖:

    最后可以把上邊提交流程再走一遍,就可以了。


作者:舊巷老友
鏈接:https://www.imooc.com/article/72092?block_id=tuijian_wz


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM