SSH gives you a command line on your Synology NAS. You use it to run Docker commands, read logs, check disks or run a script that DSM has no button for. DSM, the Synology operating system, has an SSH server built in. It is off by default.
This guide turns SSH on, connects from Windows, macOS and Linux, gets root rights with sudo -i, and sets up an SSH key that DSM accepts. We tested every step on 13 November 2026 on a Synology NAS with DSM 7.4, with a new administrator account made for the test.
Before you start
- An administrator account. DSM accepts SSH logins only from accounts in the
administratorsgroup. DSM says so on the SSH settings page: "SSH/Telnet only supports logins from accounts belonging to the administrators group." - The IP address of your NAS on your local network, for example
192.168.1.20. Synology Assistant, find.synology.com or the client list of your router shows it. - An SSH client. Windows 10 (version 1809 or later) and Windows 11 include the OpenSSH client. macOS and Linux have it in the Terminal.
How to enable SSH on a Synology NAS
- Sign in to DSM with an administrator account and open Control Panel.
- Under Connectivity, click Terminal & SNMP.

- On the Terminal tab, tick Enable SSH service.
- Keep the port 22, or type another port (see below).
- Click Apply.

Should you change the port? Another port, such as 2022, keeps out many automated scans if the port is ever reachable from the internet. It does not make SSH secure on its own. If you change it, add -p and the port to every SSH command in this guide, for example ssh -p 2022 ….
How to SSH into your Synology NAS
The command is the same on Windows, macOS and Linux. Replace youradmin with your DSM administrator account and 192.168.1.20 with the address of your NAS:
- Windows: open PowerShell or Windows Terminal (no need for "Run as administrator") and type the command.
- macOS: open Terminal (Applications, Utilities) and type the command.
- Linux: open a terminal and type the command.
At the first connection, SSH shows the fingerprint of the NAS and asks Are you sure you want to continue connecting (yes/no/[fingerprint])?. Type yes. Then type your DSM password. Nothing appears while you type it: that is normal.
DSM then shows this message and your prompt. This is the real text of DSM 7.4 (our test account is igprod):
Using terminal commands to modify system configs, execute external binary
files, add files, or install unauthorized third-party apps may lead to system
damages or unexpected behavior, or cause data loss. Make sure you are aware of
the consequences of each command and proceed at your own risk.
Warning: Data should only be stored in shared folders. Data stored elsewhere
may be deleted when the system is updated/restarted.
igprod@DiskStation:~$You are on the NAS. Type exit to close the session.
PuTTY works too, if you prefer a program with a window: type the NAS address in Host Name, the port in Port, choose SSH and click Open. The built-in ssh command does the same job without an extra download.
How to get root on a Synology with sudo -i
Since DSM 6, you cannot sign in as root with a password. Sign in with your administrator account, then type:
sudo -iType the password of your administrator account again. The first time, DSM shows the standard sudo warning:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.Your prompt now ends with #: you are root. In our test, id -u printed 0, the user ID of root. Root can change anything on the NAS, including what DSM manages itself, so use it only for the command that needs it, then type exit to go back to your own account. For Docker, sudo docker ps is enough: you do not need a root shell. Our guide to updating Docker containers on a Synology uses these commands.
How to use an SSH key with your Synology
An SSH key signs you in without your password. It is also safer: a key cannot be guessed like a password. DSM supports keys, but it needs three things: the user home service, the key in your authorized_keys file, and the right permissions on your home folder. The third one is where most setups fail.
1. Turn on the user home service
Your key lives in your home folder. In Control Panel > User & Group > Advanced, tick Enable user home service and click Apply.

2. Create a key on your computer
Skip this step if you already have a key in the .ssh folder of your computer. Otherwise, type this in PowerShell, Terminal or a Linux shell:
ssh-keygen -t ed25519Press Enter to keep the default file, and choose a passphrase if you want one. You get two files: id_ed25519, the private key that never leaves your computer, and id_ed25519.pub, the public key that you copy to the NAS. DSM 7 accepted our Ed25519 key. Older guides use RSA keys, which work too.
3. Copy the public key to the NAS
On macOS and Linux:
ssh-copy-id [email protected]Windows has no ssh-copy-id. This PowerShell command does the same thing. It sends the public key and adds it to ~/.ssh/authorized_keys on the NAS, with the permissions that SSH needs:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"Both ask for your password one last time.
4. Fix the permissions of your home folder
This is the step that most guides forget. Sign in with your password and look at your home folder:
ls -ld ~On our NAS, DSM had created the home folder like this:
drwxrwxrwx+ 1 igprod users 8 Nov 13 18:23 /var/services/homes/igprodFor SSH, rwxrwxrwx means that every user can write to the folder. The SSH server checks the permissions of your home folder before it reads your keys (its StrictModes setting, on by default), and it ignores keys in a folder that other users can change. Make the folder writable by you only:
chmod 755 ~
ls -ld ~ ~/.ssh ~/.ssh/authorized_keysOur result:
drwxr-xr-x 1 igprod users 8 Nov 13 18:23 /var/services/homes/igprod
drwx------ 1 igprod users 30 Nov 13 18:23 /var/services/homes/igprod/.ssh
-rw------- 1 igprod users 90 Nov 13 18:23 /var/services/homes/igprod/.ssh/authorized_keysThe + at the end of the first line is gone: chmod replaced the DSM permission list (ACL) of your home folder with plain permissions. That changes only your own home folder.
5. Sign in with the key
SSH no longer asks for your DSM password (only for the key's passphrase, if you set one). In our test, the key login worked on the first try after chmod 755 ~. sudo -i still asks for your DSM password: the key replaces only the login password.
How to keep SSH on your Synology safe
- Do not forward the SSH port on your router. To reach the NAS from outside, use a VPN, such as WireGuard or Tailscale, and SSH through it.
- Keep Auto Block on. In Control Panel > Security > Protection, Auto Block blocks an IP address after too many failed logins, for SSH and DSM alike.
- Use keys and a strong password for every administrator account.
- Turn SSH off when you do not need it. Untick Enable SSH service and click Apply.

Auto Block counts your own mistakes too. If you type a wrong password a few times, your computer can be blocked as well. You can remove it in Allow/Block List, from another device that can still sign in. For this reason, add the address of your own computer to the Allow list before you test SSH keys.
Synology SSH errors and how to fix them
| Error | Cause | Fix |
|---|---|---|
Connection refused | SSH is off, or you used the wrong port. | Tick Enable SSH service; use -p with the port of Terminal & SNMP. |
Connection timed out | Wrong IP address, or a firewall blocks the port. | Check the address; check Control Panel > Security > Firewall and your computer's VPN. |
Permission denied, please try again. | Wrong password, or the account is not in the administrators group. | Use an administrator account; check your password in DSM first. |
| The key is ignored and SSH asks for the password | Home folder writable by others, or user home service off. | chmod 755 ~, chmod 700 ~/.ssh, chmod 600 ~/.ssh/authorized_keys; enable the user home service. |
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! | The NAS has a new SSH host key, for example after a reset or a reinstall. | If you know why it changed, remove the old key on your computer: ssh-keygen -R 192.168.1.20, then connect again. |
Frequently asked questions
What is the default SSH port on a Synology NAS?
Port 22. You can change it in Control Panel > Terminal & SNMP. Then connect with ssh -p and the new port.
How do I log in as root on a Synology NAS?
Sign in with an administrator account, then type sudo -i and your password. DSM 6 and DSM 7 do not accept a password login as root.
Why does my Synology ignore my SSH key?
Most often, the home folder is writable by other users (drwxrwxrwx+), so the SSH server ignores the keys inside it. Run chmod 755 ~ on the NAS. Also check that the user home service is on and that ~/.ssh is 700 and authorized_keys is 600.
Can a user who is not an administrator use SSH on a Synology?
No. DSM accepts SSH and Telnet logins only from accounts in the administrators group. Other users can transfer files with SFTP, which you turn on in Control Panel > File Services > FTP.
Is it safe to open SSH to the internet?
We do not recommend it. Bots try passwords on open SSH ports all day. Use a VPN to reach your NAS from outside, keep Auto Block on and sign in with a key.
Next steps with SSH on your NAS: update your Docker containers, install Immich with Docker Compose or get Docker container alerts on Telegram.
Sources
Leave a comment
Your email address will not be published. Required fields are marked *
