First, server configuration
1. Execute ssh-keygen-t RSA generate key on each server
[email protected]. ssh]# ssh-keygen-t RSA
[email protected]. ssh]# ssh-keygen-r RSA
[email protected]. ssh]# ssh-keygen-t RSA
[email protected]. ssh]# 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:
04:45:0b:47:10:92:0c:b2:b9:d7:11:5b:49:05:e4:d9 [email protected]
2, on each server to replicate the public key on the server without logging on, such as 192.168.4.200/244/232/2014 do not need a password to log on each other, after each server generated key, on each server to execute Ssh-copy-id command , take 192.168.4.200 as an example; the other three servers are the same operation;
Example: 192.168.4.200
[Email protected] ~]# CD ~/.SSH
[email protected]. ssh]# ssh-copy-id-i id_rsa.pub "-p [email protected]"
[email protected]. ssh]# ssh-copy-id-i id_rsa.pub "-p [email protected]"
[email protected]. ssh]# ssh-copy-id-i id_rsa.pub "-p [email protected]"
[email protected] ' s password: #输入密码
Now try logging to the machine, with "SSH"-p [email protected] ' ", and check in:
. Ssh/authorized_keys
To make sure we haven ' t added extra keys so you weren ' t expecting.
The above information appears on behalf of replication success!
Above, the public key can be automatically added to the Authorized_keys file, each server will perform the above steps to achieve multiple servers without password mutual access.
Second, fault handling
1. If the Ssh-copy-id function does not exist on the remote server, as follows
[email protected]. ssh]# ssh-copy-id-i id_rsa.pub "-P 22
[Email protected] "
-bash:ssh-copy-id:command not found
Can try to use the command to solve, directly copy the local PubKey content to the remote server;
[email protected]. ssh]# Cat ~/.ssh/id_*.pub | SSH [email protected] ' cat > Ssh/authorized_keys '
Iv. Login to SSH
1. No password is required to log on to the remote server:
[email protected]. ssh]# ssh [email protected]
2, login to the remote server has ports need to add port-p
[email protected]. ssh]# ssh [email protected]-P 511190
3. You are still required to enter the remote server password, which means that your users do not have sufficient permissions on the remote server, please check your telnet user and the Authorized_keys file in which user's directory.
Server does not require password Exchange visits settings