中文 English

Latest Synology 6.17: How to Gain Root Access, Set Root Password and Enable SSH Passwordless Login

Published: 2021-02-10
dsm root SSH

1. Enable SSH Function

2. Log in to Synology via SSH Using the Default System User

ssh admin@192.168.1.5

3. After logging in, enter the following command to switch to the root account. You will need to enter your Synology login password again when prompted.

sudo -i

4. Enter the following command to navigate to the SSH directory and grant 755 permissions to sshd_config

cd /etc/ssh
chmod 755 sshd_config

5. Modify the sshd_config File Content

Enter

vi /etc/ssh/sshd_config

Press the i key to enter edit mode, find #PermitRootLogin prohibit password Change it to PermitRootLogin yes, note that the # symbol at the beginning should be removed. Press Esc to exit edit mode, enter :wq to save

6. Add SSH Public Key

cd ~
mkdir .ssh
echo ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyq1pB5aF0w6ps4OzwQl1C8uP41Iq7J+gqylLMXkoESrTUVhH1+irHuImxi2At886sO7x9s+b4jhRZoJZpZURPU4UmzUEBHKoXlqOf9eO//GtUita2AaPFw5tc0YgLPrgnO+z5MKfjo20aoJtVBvleRA/0YJcWy1a6ufXa8944D8a1Dirc9uVNR5QjKVFRbQt/twLkLdFB6t16HCwISKCVI56DcJOoY2g7mXI8clKaESeB+ANIhSKJclPwjoC6P0pHFfgqNauxC+0xugx3W2ZSIkVhdZu1L7iKvzXXPiETjPQA6qMjp/1dY2WU49Lf+wDOQplCy4HLq7QqNNVSzIBGw== Administrator@PCOS-1407251925 >> ~/.ssh/authorized_keys

7. Restart Synology

Restart via the Web界面, or directly enter reboot

8. After Restart, Log in to Synology SSH Again Using the Default System Account

ssh admin@192.168.1.5

9. Switch to the Root Account

sudo -i

10. Set the Root Default Password

synouser --setpw root xxx

11. Now You Can Log in to SSH with Root Privileges

ssh root@192.168.1.5