CentOS 6.6 ssh key password-free Login
Generate a public key and private key file --> import the content of the public key file to the local authentication file, and change the permission --> obtain the private key file for login Test
1. Generate public and private key files
[root@kvm~]
#ssh-keygen-trsa
Press enter here, or enter a password (this password is used to calculate the ssh key, not the login password)
We can see that a. ssh directory is automatically created under the/root directory, and a pair of key files are generated under the/root/. ssh directory.
Id_rsa Private Key
Id_rsa.pub Public Key
2. Import the public key file to the local authentication file and change the permission.
[root@kvm.
ssh
]
# Cat/root/. ssh/id_rsa.pub>/root/. ssh/authorized_keys # Add the public key file content to the authentication file authorized_keys.
[root@kvm.
ssh
]
# Chmod600/root/. ssh/authorized_keys # This step is very important to change the permission of the authentication file to 600.
[root@kvm.
ssh
]
# Chmod700/root/. ssh/# change the permission of the/root/. ssh directory to 700
3. Copy the private key file to another machine for verification.
3.1 Use xshell for testing in Windows
3.2 use a Linux host for testing