ssh-copy-id命令實現ssh免密登陸
ssh-copy-id -i ~/.ssh/id_rsa.pub user@ip
給github配置公鑰
首先在家目錄下自己創建一個叫.ssh
的隱藏目錄,用來存放密鑰。
生成密鑰命令:ssh-keygen -t rsa
生成密鑰全程只需要一直按回車就好,不需要輸入什麼。
運行結果會生成兩個文件:其中,右邊的id_rsa.pub
是我們需要的公鑰(左邊是私鑰,不能給別人看)
將生成的公鑰用vim打開,複製到github的https://github.com/settings/keys
點擊右邊的New SSH key
綠色按鈕,將公鑰複製進去,保存
查看公鑰是否配置成功:ssh -T [email protected]
執行這條命令後,你可能會看到告警信息,如下:
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 not provide shell access.