Guides

How to Connect to a VPS via SSH from Windows, macOS and Linux

By NileVPS Team · Published · 8 min read

اقرأ المقال بالعربي

To connect to a Linux VPS via SSH, open a terminal and run ssh root@your-server-ip, then confirm the server's fingerprint and log in with your password or SSH key. Windows 10 and 11, macOS and Linux all include an SSH client, so you do not need to install anything; PuTTY is an optional alternative on Windows. Once connected, set up SSH keys and a regular user before you do anything else.

What you need

  • The server's IP address, for example 203.0.113.10, from your control panel.
  • The username. On a fresh server this is usually root. Some cloud images use a default user instead, such as ubuntu or debian, so check what your server was set up with.
  • A password or an SSH key. Keys are more secure and more convenient, and this guide shows how to create one.
  • Port 22 reachable. If you use the NileVPS cloud firewall, allow TCP 22, ideally only from your own IP address.

If you have not created a server yet, a Linux VPS with Ubuntu 24.04 LTS or Debian 13 is a good default for following along.

Connect from Windows (Windows Terminal or PowerShell)

Windows 10 (version 1809 and later) and Windows 11 include the OpenSSH client. Open Windows Terminal or PowerShell and run:

ssh [email protected]

If you get an error that ssh is not recognised, add it under Settings > System > Optional features > Add a feature > OpenSSH Client, then open a new terminal window.

Connect from macOS or Linux

Open Terminal and run the same command:

ssh [email protected]

The first connection: host key fingerprint

The first time you connect, you will see a message like this:

The authenticity of host '203.0.113.10 (203.0.113.10)' can't be established.
ED25519 key fingerprint is SHA256:...
Are you sure you want to continue connecting (yes/no/[fingerprint])?

This is SSH asking you to confirm you are talking to the right server. Type yes and press Enter. SSH stores the fingerprint in your known_hosts file and will warn you loudly if it ever changes.

If you reinstall your server, it gets a new host key and SSH will show a "REMOTE HOST IDENTIFICATION HAS CHANGED" warning. When you know you reinstalled it, remove the old entry with ssh-keygen -R 203.0.113.10 and connect again. If you did not change anything, stop and investigate.

Then enter your password. Nothing appears on screen while you type it; that is normal. When you see a prompt such as root@server:~#, you are in.

Connect with PuTTY (Windows)

PuTTY is a long-standing free SSH client for Windows. Download it only from its official website or install it with winget install PuTTY.PuTTY.

  1. Open PuTTY.
  2. In Host Name (or IP address), enter 203.0.113.10. Keep Port at 22 and Connection type at SSH.
  3. Type a name under Saved Sessions and click Save so you can reuse it.
  4. Click Open, accept the host key, and log in as root.

PuTTY uses its own key format (.ppk). If you create keys with OpenSSH as shown below, open PuTTYgen, choose Load to import the private key, then Save private key as a .ppk file. In PuTTY, select that file under Connection > SSH > Auth > Credentials.

Set up SSH keys

An SSH key pair has a private key that stays on your computer and a public key that you place on the server. Logging in with a key is far harder to attack than a password and saves you typing.

1. Create a key on your computer

This works in Windows PowerShell, macOS and Linux:

ssh-keygen -t ed25519 -C "my-laptop"

Press Enter to accept the default file location. Set a passphrase when asked: it protects the key if your computer is ever lost or stolen. This creates two files in the .ssh folder in your home directory: id_ed25519 (private, never share it) and id_ed25519.pub (public, safe to copy).

2. Copy the public key to the server

On macOS and Linux, the easiest way is:

ssh-copy-id [email protected]

Windows does not include ssh-copy-id, but you can do the same in PowerShell:

Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | ssh [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

You can also store your public key in the SSH keys section of the NileVPS control panel, so it is ready to use with your servers instead of copying it by hand each time.

3. Test the key

Disconnect and connect again with ssh [email protected]. You should be asked for the key's passphrase (or nothing at all if you use an SSH agent), not the server password.

Make connecting easier with an SSH config file

Instead of typing the IP every time, create or edit the file ~/.ssh/config on your computer (on Windows: C:\Users\YourName\.ssh\config):

Host myvps
    HostName 203.0.113.10
    User deploy
    IdentityFile ~/.ssh/id_ed25519

Now ssh myvps is all you need.

First steps on a new Linux VPS

Do these right after your first login. The commands below are for Ubuntu and Debian; notes for Rocky Linux and AlmaLinux follow.

1. Update the system

apt update && apt upgrade -y

On Rocky Linux, AlmaLinux or CentOS Stream, use dnf upgrade -y. Reboot if a kernel update was installed.

2. Create a regular user with sudo

Working as root all the time makes mistakes more dangerous. Create a user (here called deploy) and give it administrator rights:

adduser deploy
usermod -aG sudo deploy

On Rocky Linux and AlmaLinux, use useradd -m deploy, set a password with passwd deploy, and add the user to the wheel group with usermod -aG wheel deploy.

3. Give the new user your SSH key

Copy the root user's authorised keys to the new user:

mkdir -p /home/deploy/.ssh
cp /root/.ssh/authorized_keys /home/deploy/.ssh/
chown -R deploy:deploy /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
chmod 600 /home/deploy/.ssh/authorized_keys

Open a new terminal window and check that ssh [email protected] works and that sudo whoami prints root. Keep your original session open until this works.

4. Lock down SSH and add a firewall

Once key login works for your regular user, disable password and root logins and turn on a firewall. These steps are covered carefully in our guide on how to secure a VPS, including the details that trip people up on Ubuntu cloud images.

Troubleshooting SSH connections

  • `Connection timed out`: the server is off, the IP is wrong, or a firewall blocks port 22. Check the server status and cloud firewall rules in the control panel.
  • `Connection refused`: the server is reachable but nothing is listening on port 22. The SSH service may be stopped or configured on another port.
  • `Permission denied (publickey)`: the server only accepts keys and yours was not accepted. Check you are using the right username and key, for example ssh -i ~/.ssh/id_ed25519 [email protected]. Add -v to see detailed debugging output.
  • Locked out completely: open the browser console (VNC) in the NileVPS control panel to log in directly on the server's screen and fix the configuration. If the system will not boot, rescue mode lets you mount the disk and repair files.

FAQ

What is the default SSH port?

SSH uses TCP port 22 by default. You can move it to another port, which reduces noise from automated scans, but it is not a replacement for key authentication and a firewall.

Is PuTTY better than the built-in Windows SSH client?

Neither is better for basic use. The built-in OpenSSH client uses the same commands and key files as macOS and Linux, which makes guides easier to follow. PuTTY offers a graphical interface and saved sessions, which some people prefer.

Should I use RSA or Ed25519 keys?

Ed25519 is the modern default: keys are short, fast and secure, and all current OpenSSH versions support them. Use RSA with at least 3072 bits only if you must connect to very old systems that do not support Ed25519.

Can I use the same SSH key for several servers?

Yes. Your public key can be placed on as many servers as you like. Many people use one key per device rather than one per server, so a lost laptop means removing just one key everywhere.

Next step

If you want a server to practise on, choose a distribution on the Linux VPS page and check sizes on pricing. When you are ready, deploy your VPS, add your SSH key, and follow the first steps above.

Related guides