SSH (Secure Shell) is the encrypted protocol you use to manage a VPS from the command line. To connect, you need the server's IP address, a username, and either a password or an SSH key. This guide shows how to connect from Windows, macOS and Linux, how to switch to key-based login, and what to do when the connection fails.
What you need before connecting
- the server's IP address, for example 203.0.113.10. That's a documentation-range address, so swap in your own;
- a username: root, or a user you created;
- a password, or the private key that matches a public key on the server.
If your server is on a NAT plan, the address and port will be different: you connect through a forwarded port. There's a section on that below.
Connecting from Windows
Windows 10 (version 1809 and later) and Windows 11 ship with a built-in OpenSSH client. Open PowerShell or Windows Terminal, check that it's there and connect:
ssh -V
ssh root@203.0.113.10On the first connection the client asks whether you trust the server's key fingerprint. Type yes, then enter your password. Nothing shows up while you type the password, and that's normal. If the client is missing, add it under Settings → System → Optional features → Add a feature → OpenSSH Client.
Prefer a GUI? PuTTY still works
You don't need PuTTY on a modern Windows machine, but it's fine if you want a graphical client. Download it from the official site, putty.org. Enter the IP in Host Name, leave the port at 22, pick SSH and click Open. For key login, load your private key in PuTTYgen, save it as .ppk with Save private key, and point to it under Connection → SSH → Auth → Credentials.
Connecting from macOS and Linux
On macOS, the SSH client is already available in Terminal. Most Linux distros have it installed by default. If yours doesn't, install openssh-client on Debian or Ubuntu:
sudo apt install openssh-client
ssh root@203.0.113.10Logging in with an SSH key
A password is fine for the first login, but a key is much safer: it can't be brute-forced, and the secret never travels over the network. The private key stays on your machine, and only the public key goes to the server. Generate an ed25519 key:
ssh-keygen -t ed25519 -C "laptop-2026"By default the key is saved as ~/.ssh/id_ed25519 (private) and ~/.ssh/id_ed25519.pub (public). On Windows that folder is %USERPROFILE%\.ssh. Set a passphrase: it protects the private key if the file ever ends up in the wrong hands.
Now copy the public key to the server. On Linux and macOS, ssh-copy-id is the easy way. Password login still has to work on the server at this point:
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@203.0.113.10PowerShell doesn't have ssh-copy-id, so pipe the key over instead:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh root@203.0.113.10 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"On the server, check permissions on the directory and the key file. Only the owner should have access:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keysNow test key login. Keep your current session open until you've confirmed the new one works:
ssh -i ~/.ssh/id_ed25519 root@203.0.113.10Save time with ~/.ssh/config
Tired of typing the address, user and key every time? Add an entry to ~/.ssh/config. On Windows the file lives at %USERPROFILE%\.ssh\config:
Host pulsar-web
HostName 203.0.113.10
User root
Port 22
IdentityFile ~/.ssh/id_ed25519Now ssh pulsar-web is all you need. Once you create a separate user, update the User line. Never store passwords here: the file only holds the host details and the path to your key.
Connecting through a forwarded port on NAT
A NAT VPS sits behind a shared IPv4 address, so SSH is reachable through an external port forwarded to port 22 on your machine. If the external port is 22022, you connect like this:
ssh -p 22022 root@203.0.113.10In your config file, use Port 22022 instead of Port 22. You'll find the external address and port in your provider's VPS settings. Inside the server, sshd still listens on port 22, so your ufw rule for OpenSSH stays the same.
Copying files over SSH
The same key and address work for file transfers. scp copies a file from your machine to the server. Watch out: scp uses a capital -P for the port, while ssh uses a lowercase -p:
scp ./site.tar.gz deploy@203.0.113.10:/home/deploy/
scp -P 22022 ./site.tar.gz deploy@203.0.113.10:/home/deploy/To download from the server, flip the arguments: server path first, local path second. For interactive file work, sftp gives you a simple shell for uploads and downloads:
scp deploy@203.0.113.10:/var/log/syslog ./syslog-copy.log
sftp deploy@203.0.113.10With a Host entry in your config, commands get shorter: scp ./site.tar.gz pulsar-web:/home/deploy/. The port and key come from the config, so you don't have to pass them.
Common errors and how to fix them
Permission denied (publickey) or Permission denied (password)
The server rejected the login. Usual suspects: wrong password, the key isn't in ~/.ssh/authorized_keys, wrong username, or password login is disabled. Run ssh -v root@203.0.113.10 to see which keys the client tries. You can point to the right key explicitly with -i.
Connection refused
Nothing is listening for SSH on that port. Make sure you're using the right port (on NAT, that's the external forwarded one) and that sshd is running. On the server, run:
sudo systemctl status ssh
sudo ss -tlnp | grep sshConnection timed out
Your packets aren't reaching the server. Double-check the IP, the server's firewall rules (sudo ufw status) and, on NAT, the port forwarding settings with your provider.
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Your client saved the server's key fingerprint, and now it's different. The usual reason is an OS reinstall, or the IP being reassigned to another server. But the same warning can also mean someone is impersonating the server. Confirm the reinstall actually happened, and only then remove the old entry:
ssh-keygen -R 203.0.113.10Then reconnect and compare the new fingerprint with what the server shows. If there was no reinstall, don't connect until you know why the key changed.
What's next
Once key login works, lock the server down: create a sudo user, disable password and root login, and turn on a firewall and fail2ban. The step-by-step guide is in Linux server security basics.
Still picking a server? Check out the VPS plans or read how to choose a VPS.