How to realize logging in a remote Linux via SSH without a password?
- $ssh remote@remote.linux // host key of the remote machine will be recorded in ~/.ssh/known_hosts //You need to input the password of the user remote for the first time.
- $exit //Quit from the remote machine.
- $ssh-keygen // Press Enter all the way. This will generate a key pair. For example, id_rsa and id_rsa.pub.
- $scp ~/.ssh/id_rsa.pub remote@remote.linux:~/.ssh/some //copy the public key to the remote machine. //This time you will need to input the user remote’s password.
- $ssh remote@remote.linux //Again, input the password.
- $cd ~/.ssh
- $cat some >> authorized_keys //This is the critical step.
- $exit
- $ssh remote@remote.linux //No need to enter a password any more.
Modify lines — PubkeyAuthentication yes — PasswordAuthentication yes — in /etc/ssh/sshd_config and restart the ssh server.
SSH debugging
https://www.lastupdate.net/1304.html
|