Configuring SSH password-free login takes 3 steps:
1. Generate public and private keys
2. Import the public key to the authentication file, change the permissions
3. Testing
1. Generate public and private keys
Shell Code
SSH-KEYGEN-T RSA
The default is to generate two files in the ~/.ssh directory:
Id_rsa: Private key
Id_rsa.pub: Public Key
2. Import the public key to the authentication file, change the permissions
2.1 Importing this machine
Shell Code
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
2.2 Importing a server to password-free login
First copy the public key to the server
Shell Code
SCP ~/.ssh/id_rsa.pub [email protected]:/home/xxx/id_rsa.pub
The public key is then imported into the authentication file, and this step is performed on the server
Shell Code
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
2.3 Changing permissions on the server
Shell Code
chmod ~/.ssh
chmod ~/.ssh/authorized_keys
3. Testing
SSH host, the first login may require a Yes confirmation, and then you can log in directly.
4, you can execute the command directly
SSH 10.207.139.62 ' hostname '
SSH Password-free login