Latest Synology 6.17: How to Gain Root Access, Set Root Password and Enable SSH Passwordless Login
1. Enable SSH Function
- In
控制面板->终端机和SNMP, enable theSSHfunction
2. Log in to Synology via SSH Using the Default System User
- My default user is
admin, so I enter the following command. ModifyadminandIP地址to match your own settings.
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
- Please replace with your own
SSHpublic 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
- My default user is
admin, so I enter the following command. ModifyIP地址to match your own setting.
ssh admin@192.168.1.5
9. Switch to the Root Account
- Enter the following command. You will need to enter your Synology login password again when prompted.
sudo -i
10. Set the Root Default Password
- Enter the following command, replace
xxxwith the password you want to set. Press Enter and there will be no prompt if successful.
synouser --setpw root xxx
11. Now You Can Log in to SSH with Root Privileges
- Remember to replace
IP地址with your SynologyIP地址
ssh root@192.168.1.5