Linux ssh server配置rsa登陸認證

來源:互聯網
上載者:User


Linux ssh server配置rsa登陸認證 原理:密鑰相當於一把鑰匙,而公開金鑰就相當於一把門鎖,我們當然是拿著鑰匙去開鎖,同樣的道理,我們密鑰放在本機伺服器,也就是客戶機A,把公開金鑰放在遠程伺服器,也就是遠端主機B,那麼我們就可以從客戶機A ssh免密碼登陸遠端主機B.  www.2cto.com  1、產生密匙[root@www.linuxidc.com .ssh]#ssh-keygen-t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:e4:9a:47:a7:b4:8a:0b:98:07:b8:70:de:6b:16:2c:0croot@www.linuxidc.com 2、將 /root/.ssh/id_rsa.pub改名為/root/.ssh/authorized_keys[root@www.linuxidc.com .ssh]#mv/root/.ssh/id_rsa.pub /root/.ssh/authorized_keys 3、將私密金鑰id_rsa拷貝到遠程用戶端1)如果遠程用戶端是linux,拷貝到遠程用戶端/root/.ssh/即可2)putty作為遠程用戶端putty不能識別直接從伺服器拷貝來的私密金鑰,需要使用puttygen.exe進行格式轉換(1)、開啟puttygen.exe --> Conversions --> Import Key(2)、選擇拷貝過來的私密金鑰檔案id_rsa(3)、Save private key->id_rsa.ppk(儲存私密金鑰)  www.2cto.com  4、開啟putty.exe1)、Session --> Host Name (填寫伺服器位址或者網域名稱)2)、Connection --> SSH --> Auth (點Browse選擇剛產生的id_rsa.ppk)3)、open成功開啟後出現如下提示:login as: rootAuthenticating with public key"imported-openssh-key" 當然你有可能會遇到這個錯誤 [因為我遇到了,呵呵]: Permissions 0755 for '你配置的公開金鑰檔案路徑' are too open. 這個是因為這幾個檔案使用權限設定的有點問題 執行命令: chmod 600 你的檔案 如果ssh串連緩慢可以修改/etc/ssh/sshd_config,設定GSSAPIAuthenticationno,同時設定UseDNS no,問題解決
 

聯繫我們

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