Centos SSH 免密碼互連

來源:互聯網
上載者:User

備忘:ssh免密碼互連,應該為多台伺服器間通訊,我這裡只用一台伺服器來做處理。 1,修改主機名稱。

vi /etc/sysconfig/networkNETWORKING=yesHOSTNAME=centos1
vi /etc/hosts#末尾添加 ip 主機名稱192.168.9.129 centos1
hostname centos1 #修改主機名稱臨時生效
2, 無密碼登入實現 2.1、用ssh-keygen建立公開金鑰(每台伺服器都需要執行)
[root@centos1 ~]# ssh-keygen -t rsa  Generating 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:a0:85:f4:58:d4:c7:2f:d9:ae:b1:04:91:b1:a0:9e:93 root@centos1The key's randomart image is:+--[ RSA 2048]----+|    ..+..+       ||   . * .+.o      ||    + + .o +     ||   . = .. o o    ||    E   S. o     ||     .    o .    ||         . +     ||          o      ||                 |+-----------------+

免密碼互連,直接斷行符號完成。

ssh-keygen:產生秘鑰
其中:
-t指定演算法
-f 指定產生秘鑰路徑
-N 指定密碼 2.2、查看產生的鑰匙

[root@centos1 ~]# cd .ssh/[root@centos1 .ssh]# lsid_rsa  id_rsa.pub  known_hosts
2.3 將公開金鑰複製到被管理機器下的.ssh目錄下(先確儲存在這個目錄)

我這裡是單機,就不需要執行這步操作。

接著執行

[root@centos1 .ssh]# cat id_rsa.pub >> ~/.ssh/authorized_keys  [root@centos1 .ssh]# lsauthorized_keys  id_rsa  id_rsa.pub  known_hosts
4、設定檔案和目錄許可權:

設定authorized_keys許可權

chmod 600 authorized_keys   

設定.ssh目錄許可權

 chmod 700 -R .ssh  

驗證是否成功

[root@centos1 .ssh]# ssh centos1Last login: Thu Dec 17 10:15:52 2015 from 192.168.9.1
相關文章

聯繫我們

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