Environment:
192.168.75.128 redhat6.5 x86_64
192.168.75.130 redhat6.5 x86_64
First, operate on the 192.168.75.130
1, the public key and the private key pair are generated under the ~/.ssh directory.
# Ssh-keygen
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:
E4:BB:24:9C:F9:01:A8:80:4D:DB:66:5B:47:48:C5:CA [email protected]
The key ' s Randomart image is:
+--[RSA 2048]----+
| . O. |
| . .. |
| . ... o |
|. o O. e+ |
|o o = o S |
| . + + = . |
| . . = + |
| + O |
| o |
+-----------------+
2. Ssh-copy-id appends the contents of the public key id_rsa.pub to the ~/of the remote machine. Ssh/authorized_key. File
# ssh-copy-id-i ~/.ssh/id_rsa.pub 192.168.75.128
[email protected] ' s password:
Now try logging to the machine, with "ssh ' 192.168.75.128 '", and check in:
. Ssh/authorized_keys
To make sure we haven ' t added extra keys so you weren ' t expecting.
3, log on to the remote machine does not enter the password, after landing will be the other party's information, recorded in the Known_hosts file, the first login need to enter Yes
# SSH 192.168.75.128
# SSH Slave.localdomain #如果需要主机名登陆, also need to log in early, because the first login need to enter Yes
4. No password required to log on to the machine
# ssh-copy-id-i ~/.ssh/id_rsa.pub 192.168.75.130
# SSH 192.168.75.130
# SSH Mater.localdomain
Second, do the same operation on the 192.168.75.128
1, the public key and the private key pair are generated under the ~/.ssh directory.
# Ssh-keygen
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:
E4:BB:24:9C:F9:01:A8:80:4D:DB:66:5B:47:48:C5:CA [email protected]
The key ' s Randomart image is:
+--[RSA 2048]----+
| . O. |
| . .. |
| . ... o |
|. o O. e+ |
|o o = o S |
| . + + = . |
| . . = + |
| + O |
| o |
+-----------------+
2. Ssh-copy-id appends the contents of the public key id_rsa.pub to the ~/of the remote machine. Ssh/authorized_key. File
# ssh-copy-id-i ~/.ssh/id_rsa.pub 192.168.75.130
[email protected] ' s password:
Now try logging to the machine, with "ssh ' 192.168.75.130 '", and check in:
. Ssh/authorized_keys
To make sure we haven ' t added extra keys so you weren ' t expecting.
3, log on to the remote machine does not enter the password, after landing will be the other party's information, recorded in the Known_hosts file, the first login need to enter Yes
# SSH 192.168.75.130
# SSH Master.localdomain #如果需要主机名登陆, also need to log in early, because the first login need to enter Yes
4, the landing of the machine does not require a password, if there is a login host name,
# ssh-copy-id-i ~/.ssh/id_rsa.pub 192.168.75.128
# SSH 192.168.75.128
# SSH Slave.localdomain
Reference: http://blog.chinaunix.net/uid-26284395-id-2949145.html
This article from the "Small Fish Blog" blog, reproduced please contact the author!
Linux Dual-Machine Trust