標籤:-o lan permanent 點擊 編輯 ssh公開金鑰 href tar rsa
檢查SSH keys的設定
$ cd ~/.ssh/
如果顯示”No such file or directory”,跳到第三步,否則繼續。
備份和移除原來的SSH key設定
如果已經存在key檔案,需要備份該資料並刪除之
$ lsid_rsa id_rsa.pub known_hosts$ mkdir key_backup$ cp id_rsa* key_backup/$ rm id_rsa*
產生新的SSH key
輸入下面的代碼,可以產生新的key檔案,只需要使用預設的設定即可,當需要輸入檔案名稱的時候,斷行符號即可
$ ssh-keygen -t rsa -C "你的郵箱@qq.com"Generating public/private rsa key pair.Enter file in which to save the key (/c/Users/WX/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /c/Users/WX/.ssh/id_rsa.Your public key has been saved in /c/Users/WX/.ssh/id_rsa.pub.The key fingerprint is:1d:cc:7e:b3:7e:92:f7:ab:c6:75:56:73:62:30:bc:8c 你的郵箱@qq.comThe key‘s randomart image is:+--[ RSA 2048]----+| . || o + || +o + || oE.o o.o|| S o o. .+|| . o .o|| o....|| .ooo || o=.oo|+-----------------+
Enter passphrase (empty for no passphrase):這裡可以輸入密碼,在登入時驗證
添加SSH key到GitHub
用文本編輯工具開啟id_rsa.pub檔案,如果看不到這個檔案,你需要設定顯示隱藏檔案。準確的複製這個檔案的內容,才能保證設定的成功。
在GitHub的首頁上點擊設定按鈕,選擇SSH Keys項,把複製的內容粘貼進去,然後點擊Add Key按鈕即可,Title任意選擇。
測試一下
輸入下面命令,測試是否設定成功(第一次登入)
$ ssh -T [email protected]The authenticity of host ‘github.com (192.30.255.112)‘ 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)? yWarning: Permanently added ‘github.com,192.30.255.112‘ (RSA) to the list of known hosts.Enter passphrase for key ‘/c/Users/dyf/.ssh/id_rsa‘:(如果上一步設定密碼 這裡需要輸入)Hi dyf007! You‘ve successfully authenticated, but GitHub does not provide shellaccess.
參考:http://codepub.cn/2015/06/02/Windows-client-configuration-of-SSH-public-key-on-GitHub/ (這裡有設定多個sshKey的說明)
Windows用戶端配置GitHub的SSH公開金鑰