SSH password-free login to use public and private keys. You can use Ssh-keygen to generate a public/private key pair under Linux.
1. Generate a public/private key pair under a machine
$ssh-keygen-t rsa-p "'
-P for the password,-p ' means the empty password, you can not use the-p parameter, so that three cars to enter, with-P on a return.
It generates the. SSH directory under/home/x, with Id_rsa (private key) and id_rsa.pub (public key) under SSH.
2, the id_rsa.pub under a machine copy to B machine, in the B machine. ssh/authorized_keys file, with SCP replication.
$SCP. ssh/id_rsa.pub [Email protected]:/home/x/id_rsa.pub
[email protected] ' s password:
Id_rsa.pub 100% 223 0.2kb/s 00:00
Since there is no password-free login, enter the password.
3, B machine to copy from a machine id_rsa.pub added to the. ssh/authorzied_keys file.
Note: If you are running SSH for the first time, the. SSH directory needs to be created manually or using the command ssh-keygen-t RSA to generate the secret key, which automatically generates the. SSH directory in the user directory. Pay special attention to the. SSH directory permissions issue, remember to run the chmod. SSH command
$cat id_rsa.pub >>. Ssh/authorized_keys
$chmod Ssh/authorized_keys.
Authorized_keys's permission is
The permissions for the. SSH directory are 700
Home directory permissions are not writable for groups
$rm ~/id_rsa.pub (Safe, remove public key)
4, a machine login B machine.
$ssh [email protected]
Is you sure-want to continue connecting (yes/no)? Yes
The first time you log in is when you want to enter Yes. Records are added to the. ssh/known_hosts file.
Finally, the SSH client needs a private key, and the SSH server has a public key to enable password-free. If you want to allow A/b machine password-to-log, the B machine can be configured in the same manner as above.
Tips:ssh HOSTNAME-VVVV can display more debugging information
SSH logs in/var/log/secure
This article is from the Linux Essentials blog, so be sure to keep this source http://chaoyuezhangsan.blog.51cto.com/7176886/1771797
CentOS 6.7 ssh Password free