1. Blog
  2. Manuals

How to Connect to a Server via SSH: Windows, Linux, macOS

How to Connect to a Server via SSH: Windows, Linux, macOS

SSH is the main way to manage a Linux server: you get the remote machine’s command line over an encrypted channel. Below is how to connect from any operating system, set up key-based login, and what to do when the connection fails.

What you need

After ordering a virtual server you receive an email with the access details:

  • the server’s IP address, for example 203.0.113.10;
  • the login — usually root;
  • a password or a pre-installed SSH key;
  • the port — 22 by default.

Connecting from Linux and macOS

The OpenSSH client is already installed. Open a terminal and run:

ssh root@203.0.113.10

If the server listens on a non-standard port, pass it with -p:

ssh -p 2222 root@203.0.113.10

On the first connection the client shows the server’s key fingerprint and asks whether you trust it. Type yes — the fingerprint is saved to ~/.ssh/known_hosts and you will not be asked again. Then enter the password: nothing is displayed as you type, which is normal.

Connecting from Windows

Built-in OpenSSH client

Windows 10 and 11 ship with an SSH client. Open PowerShell or Terminal and use the same command:

ssh root@203.0.113.10

If the command is not found, install the feature: Settings → Apps → Optional features → OpenSSH Client.

PuTTY

PuTTY is handy if you want saved sessions or work on an older version of Windows.

  1. Download PuTTY from the official site and start it.
  2. Enter the server’s IP address in Host Name (or IP address) and the port in Port.
  3. Under Window → Translation, select UTF-8 so that non-Latin characters display correctly.
  4. Go back to Session, type a name in Saved Sessions and click Save.
  5. Click Open, accept the server fingerprint and enter the login and password.

Logging in with an SSH key

A key is safer than a password: it cannot be brute-forced, and there is nothing to type.

Create a key pair on your computer (the command is the same on Linux, macOS and Windows):

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

Copy the public key to the server. On Linux and macOS:

ssh-copy-id root@203.0.113.10

Windows has no ssh-copy-id, so use PowerShell:

type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh root@203.0.113.10 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Make sure key-based login works, and only then disable password login. In /etc/ssh/sshd_config on the server set:

PasswordAuthentication no

and restart the service:

systemctl restart ssh

Short names for servers

To avoid typing the address, port and login every time, describe the server in ~/.ssh/config:

Host web
    HostName 203.0.113.10
    User root
    Port 2222
    IdentityFile ~/.ssh/id_ed25519

Now ssh web is enough. scp, rsync and sshfs understand the same names.

Common errors

Message Cause and fix
Connection refused The SSH service is not running, or the port is wrong. Check the port and the server status in the control panel.
Connection timed out The server is off, the IP is wrong, or a firewall blocks the port.
Permission denied Wrong login, password or key. Password login for root may be disabled in sshd_config.
REMOTE HOST IDENTIFICATION HAS CHANGED The server was reinstalled and its key changed. Remove the old entry: ssh-keygen -R 203.0.113.10.

Debug mode shows why a connection is refused: ssh -v root@203.0.113.10.

What to set up after the first login

Bots start scanning a server with port 22 open within minutes. The minimum protection: