How to enable passwordless SSH login to a Synology NAS
Several things need to be done to allow passwordless SSHing into a Synology NAS box. This guide was written against DSM 6.2.1-23824 Update 1.
- Enable support for SSH on the Synology target machine
- Click the Control Panel Icon
- Choose Terminal & SNMP
- Check Enable SSH service
- Allow the user, on the Synology target machine, to SSH
- Edit /etc/passwd
- Change the command/shell of the user that will SSH into the box from /sbin/nologin to /bin/sh
- Read this to understand the format of the /etc/passwd file a bit better.
- Add the authorized key of the client to the authorized_keys file of target
- on the client run ssh-keygen
- copy the .pub file (likely something like /home/user/.ssh/id_ecdsa.pub) to the target machine with a command like
scp /home/user/.ssh/id_ecdsa.pub target_user@target_server:/var/services/homes/target_user/.ssh/id_ecdsa.pub
- either rename id_ecdsa.pub to authorized_keys or copy the contents into your authorized_keys file.
- SSH once manually from the client machine (as the SSHing client user) to the target machine to add the target machine to the client's known_hosts file.