Both sides
.ssh
dir should be 700 or drwx——
Client side
Generate keys:
$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/urlogin/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/urlogin/.ssh/id_rsa. Your public key has been saved in /home/urlogin/.ssh/id_rsa.pub. The key fingerprint is: SHA256:XXX...---...XXX urlogin@urhost.tdn The key's randomart image is: +---[RSA 2048]----+ .... +----[SHA256]-----+ $ ls -lh total 8.0K -rw------- 1 urlogin urgroup 1.8K Aug 24 08:41 id_rsa -rw-r--r-- 1 urlogin urgroup 412 Aug 24 08:41 id_rsa.pub
Server side
Copy id_rsa.pub
to ~/.ssh and add it to authorized_keys
or authorized_keys2
:
cat .id_rsa.pub >> authorized_keys
Ensure authorized_keys
is rw only for user:
chmod 600 authorized_keys
Troubleshooting
If message appears:
sign_and_send_pubkey: signing failed: agent refused operation
There is a problem with ssh-agent:
$ eval `ssh-agent -s` $ ssh-add