How to connect to your VPS over SSH
SSH is how you control a VPS from the command line, and setting it up properly the first time saves you a lot of trouble later.
SSH — Secure Shell — is the encrypted connection you use to control a Linux VPS from a terminal. There is no desktop, no icons, no mouse. Everything you do to the server, from installing software to reading its logs, starts with an SSH connection, so getting it working properly is the actual first step of owning a VPS.
You need three things before you begin: the server's IP address, a username, and either a password or an SSH private key. Your host sends these in a welcome email, or shows them in your control panel — see current plans at /vps-hosting if you have not provisioned a server yet.
Connecting from macOS or Linux
Both ship an SSH client already. Open Terminal and run:
ssh root@203.0.113.10
Replace root with the username you were given and the address with your actual server IP. The first time you connect to a given server, you will see something like this:
The authenticity of host '203.0.113.10' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Type yes. This is SSH recording the server's identity so it can warn you later if it ever changes unexpectedly — which is exactly what happens if someone reinstalls the server, or, far less innocently, if something is intercepting your connection. Type the password when prompted, and you are in.
Connecting from Windows
Current versions of Windows include the OpenSSH client in PowerShell and Windows Terminal, so the same command works with no extra software:
ssh root@203.0.113.10
If that command is not recognised, install the optional OpenSSH client from Windows Settings under "Optional Features", or use PuTTY instead. In PuTTY, enter the IP address in the "Host Name" box, leave the port at 22, click Open, accept the host key prompt, then log in at the black window that appears.
Most VPS images boot with only a root account. Logging in as root to do the initial setup is normal and expected — the next job, covered in creating a non-root sudo user, is to stop using it for everyday work once the server is set up.
Setting up key-based login
A password can be guessed or brute-forced. An SSH key pair — a private key that stays on your computer and a public key placed on the server — cannot be, in any practical sense, and it is also faster to use since there is nothing to type. Generate one on macOS, Linux, or modern Windows:
ssh-keygen -t ed25519 -C "you@example.com"
Accept the default file location by pressing Enter, and set a passphrase if you want an extra layer of protection on the key file itself. This creates two files: a private key (id_ed25519, never shared) and a public key (id_ed25519.pub, safe to copy anywhere).
Copy the public key to the server. On macOS or Linux, the simplest way is:
ssh-copy-id root@203.0.113.10
If that command is not available — it is not on Windows — copy it manually instead:
cat ~/.ssh/id_ed25519.pub | ssh root@203.0.113.10 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
Once a key is installed, it is tempting to immediately switch off password authentication in sshd_config. Do not do that yet. Keep your current session open, open a completely new terminal window, and confirm ssh root@203.0.113.10 logs you in with no password prompt. Only disable password authentication once that second session has actually succeeded — if you disable it first and the key does not work for some reason, you have just locked yourself out with no way back in except your host's rescue console.
Once the key is confirmed working, disable password authentication by editing /etc/ssh/sshd_config:
sudo nano /etc/ssh/sshd_config
Set:
PasswordAuthentication no
PermitRootLogin prohibit-password
Then reload SSH — the service is called ssh on Debian and Ubuntu, and sshd on RHEL, Rocky Linux and AlmaLinux:
sudo systemctl restart ssh # Debian / Ubuntu
sudo systemctl restart sshd # RHEL / Rocky / AlmaLinux
Leave your existing session open while you do this, and test a fresh connection in a new window straight afterwards, exactly as before.
Common connection problems
| Message | Usual cause |
|---|---|
Connection refused | SSH is not listening, the port is wrong, or a firewall is blocking it. See setting up a firewall. |
Connection timed out | Nothing answered at all — check the IP address, or the server may still be booting. |
Permission denied (publickey) | The server only accepts keys and does not have yours. Point ssh at the right private key with -i. |
Permission denied (publickey,password) | Neither your key nor your password matched. Double-check the username — it is easy to try root on a server where you created a different account. |
REMOTE HOST IDENTIFICATION HAS CHANGED | The server's host key no longer matches what you saw before. Legitimate after a reinstall; otherwise treat it as suspicious and verify with your host before proceeding. |
Once you can connect reliably, the next jobs are creating a proper user account and locking down the firewall — see how to create a non-root sudo user and how to secure a new Linux server. If you manage to lock yourself out entirely, this guide covers getting back in.
Frequently asked questions
Why does it say "Connection refused"?
Either SSH is not running on the server, it is listening on a different port than the one you used, or a firewall between you and the server is blocking it. If you have not touched the firewall yet, this is usually the VPS still booting — wait a minute and try again.
Why does it say "Permission denied (publickey)"?
The server has been set to accept only key-based logins, and it does not have a key from you. You need the private key that matches a public key already installed on the server, supplied to ssh with -i /path/to/key.
Related reading
Why root should not be your daily account, and the exact commands to create a proper sudo user in its place on any major distribution.
How to set up a firewall on your VPSHow to enable and configure a firewall on your VPS with ufw or firewalld, without accidentally shutting yourself out over SSH.
What to do when you are locked out of your VPSThe browser-based console gets you back in even when SSH will not, and then the same handful of causes cover almost every lockout.
How to transfer files to a server with SCP and SFTPCopying files to and from a VPS with scp, sftp and rsync, and connecting a graphical tool like FileZilla when a terminal is not what you want.