Last Updated on August 14, 2022 by Thiago Crepaldi
For future posts, we will need to have SSH enabled on the Synology NAS, so let’s get this out of the way.
Although you can use admin user to connect to Synology DSM, you can create a new user for this purpose. Go to Control Panel >> User and click the Create button, fill in your info and click on Next. In the next screen, add the administrators group to the new user block checking the check box. Click Next until you get to the summary step, in which you click Apply.
Now that you have a viable user, go to Control Panel >> Terminal & SNMP >> Terminal and check the Enable SSH service, optionally change the default Port and click Apply.
From another machine, test your configuration by running ssh <your_user>@<synology_ip>.
Installing private/public keys for your SSH user
After going through the steps from the previous section, you will be able to SSH into your Synology NAS. However, we will also need to SSH from your NAS into other devices for automation.
To accomplish this, you have to either generate a new SSH key or copy your existing into your DSM. If you generated your keys after login in to your DSM, you are done. In order to copy your keys to your NAS, use scp ~/.ssh/id_rsa* <synology_username>@<synology_ip>:~/.ssh. From now on, not only you can connect into your Synology, but also connecting from your Synology to other devices.
Sometimes scp does not preserve file permissions and SSH’ing from Synology might ask you for password. To fix this, run chmod 644 ~/.ssh/id_rsa.pub and chmod 700 ~/.ssh/id_rsa.