實現SSH無密碼登入:使用ssh-keygen和ssh-copy-id

來源:互聯網
上載者:User

標籤:

 

ssh-keygen 產生公開金鑰與私密金鑰對.
ssh-copy-id 將原生公開金鑰複製到遠程機器的authorized_keys檔案中,ssh-copy-id也能讓你有到遠程機器的/home/username/.ssh和~/.ssh/authorized_keys的權利.


操作記錄:
1)第一步:在本地機器上使用ssh-keygen產生公開金鑰私密金鑰對
#ssh-keygen -t rsa [一路預設斷行符號]
這樣就會在目前使用者家目錄下的.ssh目錄裡產生公開金鑰和私密金鑰檔案:id_rsa.pub、id_rsa

2)用ssh-copy-id將公開金鑰複製到遠程機器中
#ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] [把原生公開金鑰拷貝到遠程機器上,比如B機器]

注意: ssh-copy-id 將key寫到遠程機器的 ~/ .ssh/authorized_key.檔案中

3)這樣,本機登入到上面遠程機器(B機器)就不用輸入密碼
#ssh [email protected]

 

實現SSH無密碼登入:使用ssh-keygen和ssh-copy-id

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.