SSH keyless entry is simple and can be deployed in just three or four steps.
Test environment: CentOS 6.6
The steps are as follows:
1. Generate the public key and key on Host a!
[[email protected] ~]# ssh-keygen-t RSA #一直回车即可! 650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/A1/wKiom1YCZvDBs6pwAAHjNuMCDCo129.jpg "title=" 1.png " alt= "Wkiom1yczvdbs6pwaahjnumcdco129.jpg"/>
2. After completion of the previous step, a. SSH directory is generated under the host directory of the user you are currently logged into, and two files (Id_rsa and id_rsa.pub) private and public keys are generated under the. SSH Directory
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/9E/wKioL1YCaFuxuE8_AABVZF-YXeQ303.jpg "title=" 2.png " alt= "Wkiol1ycafuxue8_aabvzf-yxeq303.jpg"/>
3. Move the public key (Id_rsa.pub) to the. SSH directory under the user's home directory for the server that you want to password-free login to and rename to Authorized_keys
[Email protected] ~]# SCP ~/.ssh/id_rsa.pub [email Protected]:/home/user/.ssh/authorized_keys
Remarks: If there is already a authorized_keys in the. SSH directory under the user home directory of the server that requires a key-free login, append the public key to the file and change it if the content is overwritten! (This content is only suitable for multiple server-free keys to log on to this server)
4. Permissions to directories and files:
chmod 700/home/user/.ssh
chmod 600/home/user/.ssh/authorized_keys
5. Testing
Using ServerA SSH ServerB, no prompt for password and success, the first login will prompt you to enter "YES"!
Remarks: If your demand is: There are more than n servers need to key-free login, then this public key file will be the SCP how many times? All you can do is deploy the Web service on your servera, then copy the public key to the root of the website, download the public key on the other server via the Web, and then write a very simple script to perform steps 3, 4!
This article is from the "aestheticism" blog, make sure to keep this source http://cctian.blog.51cto.com/10445650/1697532
Deploying SSH Key-free logins