The requirement to ssh to server without password
To ssh without password, you must meet the condition:
- Private key in client
~/.ssh/
- Public key in server
~/.ssh/authorized_keys
Steps to setup
Create ssh key pairs by ssh-keygen
1
2
3
4
5
6
7# Generate key
ssh-keygen
# Check the generated key pair
ls ~/.ssh
-rw------- 1 sing staff 1679 Jun 8 2018 id_rsa
-rw-r--r-- 1 sing staff 404 Jun 8 2018 id_rsa.pubLogin to your server
Copy the content of the publicKey (id_rsa.pub) to server’s
~/.ssh/authorized_keys
1
echo "${public key content}" >> .ssh/authorized_keys
Verify ssh without password
1
ssh [email protected]