March 24, 2017

Login to Synology NAS with SSH Keys

On the host you want to be able to login from:

run "ssh-keygen -t rsa" make sure to have a blank passphrase

cat /root/.ssh/id_rsa.pub and save that info for later

On the Synology NAS

Edit /etc/ssh/sshd_config change

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

to this:

#RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

Add the necessary files, folders and permissions

mkdir /root/.ssh
touch /root/.ssh/authorized_keys
chmod 700 /root/.ssh
chmod 644 /root/.ssh/authorized_keys

Add your pub key to /root/.ssh/authorized_keys:

echo "ssh-rsa yourkey youruser@yourhost" >> /root/.ssh/authorized_keys

Done!

No comments: