In the development, often need to ssh from one host to another host, each time need to lose login/password, very cumbersome.
Use the key to log in, you can not enter the user name and password
Implementing a password- free login from host A to Host B requires the following steps:
1. Execute command "ssh-keygen-t RSA" in Host a "~/.ssh/" (build process, all the way to enter), generate two files Id_rsa and id_rsa_pub, these two files are actually a key pair, Id_rsa is the private key, Id_rsa_pub is a public key;
2. Copy the file id_rsa_pub from Host a (can use SCP command) to Host B "~/.ssh/" directory;
3. Log on to Host B, enter the "~/.ssh/" directory and add the Id_rsa_pub file from the host to the file "Authorized_keys" tail (cat Id_rsa_pub>>authorized_keys), if the file "Authorized_keys" does not exist, it is created; the "~/.ssh/authorized_keys" permission is at least 600;
4. From Host a login Host B, the first time when the Host B to automatically set the Known_hosts file, so you need to enter Yes, no need for the future;
P.S. Of course, you log in to host A and Host B with the same user name
Configure the user's public key login, configure the Authorized_keys incredibly has been not effective, so Google, found that the original is because. SSH directory and the permissions of the following files caused by the problem, because the permissions of the directory has exceeded the requirements of sshd permissions.
If you want the SSH public key to take effect, at least two of the following conditions will be met:
1). SSH directory permissions must be
2). ssh/Authorized_keys file permissions must be 600
Icing on
Assuming that your username is user, the key login Host B has been set. Then you can define an alias in the shell configuration file (e.g.. BASHRC)
Alias b= ' ssh [email protected] '
After each time you start the shell terminal, enter B, return, directly on the SSH login to Host B.
http://blog.csdn.net/yasaken/article/details/7420093
Linux SSH key automatic login (GO)