使用ssh-keygen,實現免密碼登陸linux

來源:互聯網
上載者:User

使用ssh-keygen,實現免密碼登陸linux 本機為192.168.1.2 伺服器為192.168.1.3  首先在原生使用者目錄下用命令產生key  ssh-keygen -t rsa 根據提示按4個enter鍵,就產生了我們要使用的在key 進入.ssh/目錄 可以看到剛才產生的檔案id_rsa.pub  把這個檔案上傳到伺服器上的根目錄下的.ssh/目錄下 scp -p id_rsa.pub username@192.168.1.3:.ssh/  在伺服器上把id_rsa.pub改名 mv id_rsa.pub authorized_keys,如果伺服器上已經有authorized_keys,這時可以用 cat id_rsa.put >> authorized_keys 把我們產生的key追加到authorized_keys檔案的後邊就可以了  然後變更檔的許可權 chmod 600 authorized_keys  ok 現在在本地用ssh userName@192.168.1.3就可以直接登陸了,不用密碼了 

聯繫我們

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