To set up SSH on a Linux VPS, you need the server’s IP address, the root password from your welcome email, and an SSH client. Below, you’ll find a step-by-step guide to setting up SSH, along with instructions for the SSH config file, changing the SSH port, and using port forwarding.
What are SSH and SSH keys?
Secure Shell (SSH) is a cryptographic network protocol that allows data to be transferred using a secure channel between digital devices. It’s the standard method for securely connecting to a Linux VPS.
Primarily used in Linux and Unix multi-user operating systems, SSH has been developed as a replacement for Telnet and other insecure remote access protocols that send unencrypted information, notably passwords, making them vulnerable to discovery through traffic analysis.
Encryption used by SSH is used to ensure the confidentiality and integrity of data transmitted through an insecure network such as the Internet.
SSH keys provide a safer way to log in to an SSH server than a password. While a brute force attack can eventually discover a password, SSH keys are almost impossible to crack with brute force alone.
Generating a key pair gives you two files: a public key and a private key. You place the public key on any server you want to access; the private key stays on your computer. When you connect, the server checks that your client holds the private key that matches the public key, and lets you in without a password. You can increase security even more by protecting your private key with a passphrase.
How do you connect to a server with SSH?
Open a terminal (PowerShell on Windows) and run:
ssh [email protected]
Use your VPS address instead of the example IP. On the first connection, SSH shows the server’s fingerprint; type yes to save it. Then paste the root password from your welcome email.
Windows 10 (version 1809 and later) and Windows 11 include the OpenSSH client. If you prefer PuTTY, enter the IP, keep SSH port 22 and click Open, as shown in our connection video.
How do you generate an SSH key?
You can generate a key pair on your own computer:
ssh-keygen -t ed25519 -C "laptop-2026"
Accept the default location and set a passphrase. You’ll get id_ed25519 (private, never leaves your machine) and id_ed25519.pub (public). Ed25519 has been the OpenSSH default since version 9.5. Then copy the public key to the server:
ssh-copy-id [email protected]
Windows doesn’t include ssh-copy-id. In PowerShell, run this instead:
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"
With us, you can skip this for new servers: add the public key under SSH Keys in the client panel, and it’s installed on every VPS you order afterwards (how the SSH Keys feature works). For servers you already have, copy the key with one of the commands above.
How to set up SSH so passwords aren’t accepted?
Once key login works, turn off passwords in /etc/ssh/sshd_config:
PasswordAuthentication no
PermitRootLogin prohibit-password
Check for files in /etc/ssh/sshd_config.d/ as well. On many cloud images, a file such as 50-cloud-init.conf sets PasswordAuthentication, and because SSH uses the first value it reads, that file wins over your edit. You can change or remove the line there too. Then check the syntax with sshd -t.
Restart with systemctl restart ssh (sshd on AlmaLinux and Rocky Linux). Test in a new session before closing the current one, or a typo can lock you out.
More tips can be found in our guide to public key authentication on Linux. To keep the private key on a hardware token, see YubiKey for SSH on Windows or read how to add your existing SSH Key to YubiKey via OpenPGP.
How do you change the SSH port?
The default SSH port is 22. Moving it to, say, 2222 won’t stop a targeted attack, but it removes most automated login noise from your logs. Do it in this order:
- Allow the new port: ufw allow 2222/tcp.
- Set Port 2222 in /etc/ssh/sshd_config.
- On Ubuntu 22.10 and newer, SSH uses socket activation (2): run systemctl daemon-reload and systemctl restart ssh.socket. Elsewhere, restart sshd.
- Test from a second terminal: ssh -p 2222 [email protected].
What goes in the SSH config file?
The SSH config file (~/.ssh/config on your computer) stores settings for each server:
Host myvps
HostName 203.0.113.10
User root
Port 2222
IdentityFile ~/.ssh/id_ed25519
Now ssh myvps is enough. scp, rsync and VS Code Remote-SSH read the same file, so you only learn how to set up SSH connections once.
How does SSH port forwarding work?
SSH port forwarding sends traffic through the encrypted connection, so you can reach services that listen only on localhost, like a database panel.
|
Type |
Command |
Typical use |
|---|---|---|
|
Local (-L) |
ssh -L 8080:localhost:80 myvps |
Open a VPS panel at localhost:8080 |
|
Remote (-R) |
ssh -R 9000:localhost:3000 myvps |
Expose an app from your laptop through the VPS |
|
Dynamic (-D) |
ssh -D 1080 myvps |
Use the VPS as a SOCKS proxy |
Add -N if you want the tunnel without a shell. Every MVPS Linux VPS comes with full root SSH access, in locations across Europe. If you need help along the way, don’t hesitate to contact us at [email protected].


