利用公開金鑰私密金鑰解決Linux中git clone git庫需要輸入密碼的問題__Linux

來源:互聯網
上載者:User

建立認證登入:

收集所有需要登入的使用者的公開金鑰,公開金鑰位於id_rsa.pub檔案中,把我們的公開金鑰匯入到git庫所在linux伺服器的/home/git/.ssh/authorized_keys檔案裡,一行一個。

如果沒有該檔案則建立它且修改對應檔案的許可權:

$ cd /home/git$ mkdir .ssh$ chmod 700 .ssh$ touch .ssh/authorized_keys$ chmod 600 .ssh/authorized_keys

使用者上的公開金鑰和私密金鑰:

1.首先查看其是否有。

$ cd ~/.ssh$ ls

尋找id_rsa與id_rsa命名的檔案,一個是.pub副檔名(公開金鑰),另一個為私密金鑰。
2.如果沒有則使用ssh-keygen建立,連續按斷行符號鍵,表示使用私密金鑰時不輸入口令。
在.ssh下面產生了2個檔案id_rsa與id_rsa.pub(公開金鑰)。
特別注意點:

1.git上的倉庫對git使用者要有寫入權限,同時需要將/etc/ssh/sshd_config中將RSA認證開啟,即

RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keys

2./home/git屬於git使用者所有,且許可權為755即drwxr-xr-x。
3.確保.ssh/authorized_keys中每個使用者的id_rsa.pub(公開金鑰)為ssh-rsa開頭。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.