Environment:
Local Host: HA01
ETH0:192.168.1.100//External IP address
Remote host: HA02
ETH0:192.168.1.200//External IP address
Local Host HA01 configuration:
Copy Code code as follows:
[Root@ha01/]# Cd/etc/ssh
[Root@ha01 ssh]# ssh-keygen-t rsa-n "" (This step generates a key public-private key pair,-n "" indicates that the key pair phrase is empty)
Generating public/private RSA key pair.
Enter file in which to save the key (/ROOT/.SSH/ID_RSA):
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:
82:2c:74:43:8e:16:f4:ef:ac:91:0f:d7:6f:a6:f3:59 ROOT@HA01
Copy public key to remote host (original method):
If the/root/.ssh/authorized_keys file does not exist on the HA02 server
Copy Code code as follows:
[Root@ha01 ssh]# scp/root/.ssh/id_rsa.pub Root@192.168.1.200:/root/.ssh/authorized_keys
If the Authorized_keys file exists
Execute on HA01:
Copy Code code as follows:
[Root@ha01 ssh]# scp/root/.ssh/id_rsa.pub root@192.168.1.200:/root/.ssh/
Execute on HA02:
Copy Code code as follows:
[Root@ha02/]# cat/root/.ssh/id_rsa.pub >>/root/.ssh/authorized_keys
To copy a public key to a remote host (new method):
You can use Ssh-copy-id to easily copy public keys to a remote host
Execute on HA01:
Copy Code code as follows:
[Root@ha01 ssh]# ssh-copy-id-i ~/.ssh/id_rsa.pub root@192.168.1.200
SSH Login Test:
Copy Code code as follows:
[Root@ha01 ssh]# ssh ha02
Last Login:fri APR 8 10:41:28 from HA01