There are many tutorials on the Internet, but they are recorded for later use.
The Intranet ip addresses of the two servers are:
172.16.3.91 (Local Machine)
172.16.3.92 (remote host)
Now I want to log on to the remote machine through ssh 172.16.3.92 on the local machine without a password.
1. Use ssh-keygen to create the public key and private key on the local machine.
[Root @ RS-1 ~] # 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:
Dc: fc: ea: b8: bb: 74: d7: 75: 4b: 6a: 27: 82: 28: 27: be: d6 root @ RS-1
In this process, you will be prompted to enter the password. Remember to press enter directly. Do not enter the password! If you have entered the password, you need to enter the password for access later.
After creation, you can see the following two files:
[Root @ RS-1. ssh] # ll
Total 24
-Rw ------- 1 root 1675 May 8 07:18 id_rsa
-Rw-r -- 1 root 391 May 8 id_rsa.pub
Id_rsa is the private key.
Id_rsa.pub is a public key, mainly used by remote machines.
2. Upload the public key to the remote machine.
[Root @ RS-1. ssh] # scp id_rsa.pub root@172.16.3.92 :~ /. Ssh/authorized_keys
Address 172.16.3.92 maps to localhost, but this does not map back to the address-possible break-in attempt!
Root@172.16.3.92's password:
Id_rsa.pub 100% 391 0.4KB/s
3. You do not need a password when connecting to the ssh client. You can directly log on to the remote server.
[Root @ RS-1. ssh] # ssh 172.16.3.92
Address 172.16.3.92 maps to localhost, but this does not map back to the address-possible break-in attempt!
Last login: Thu May 8 07:19:28 2014 from 172.16.3.91
[Root @ RS-2 ~] #