建立linux主機間信任關係

簡明:shell腳本建立linux主機間信任關係。
1、確保已建立信任連接。
建立信任連接方法。在A生成ssh空密碼密鑰,並拷貝到B。

    $ ssh-keygen -t rsa 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/damon/.ssh/id_rsa): 
Created directory '/home/damon/.ssh'.
Enter passphrase (empty for no passphrase): #不輸入密碼
Enter same passphrase again: 
Your identification has been saved in /home/damon/.ssh/id_rsa.
Your public key has been saved in /home/damon/.ssh/id_rsa.pub.
The key fingerprint is:
48:22:5e:35:93:ae:d1:04:03:5a:69:ff:eb:a9:c9:6a [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|  ooo.+.         |
| oo  ooo         |
|....o+.          |
| . oooo.         |
|  .  +. S        |
|    . .          |
|       .         |
|  E. ...         |
| ...+oo          |
+-----------------+

拷貝公鑰。

    $ scp .ssh/id_rsa.pub damon@192.168.0.188:/home/damon/.ssh/id_rsa.pub1

遠程到B,並把公鑰寫入~/.ssh/authorized_keys。

    $ cat id_rsa.pub1 >> authorized_keys

設置文件權限。.ssh爲700,authurized_keys爲600。

    $ chmod 700 .ssh
    $ chmod 600 authorized_keys

此時,可以在A中空密碼遠程到B。

    $ ssh 192.168.0.188
Last login: Mon Aug 24 08:53:51 2015
    $
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章