Blog
3 min read

How to SSH Into a Server (Mac, Windows and Linux)

SSH lets you open a terminal on a remote server securely. How to connect from macOS, Windows and Linux, logging in with a password vs an SSH key, the first-connection fingerprint prompt, a config file shortcut, and fixes for the common connection errors.

SSH (Secure Shell) lets you open a terminal on another computer — usually a server in a data centre — over an encrypted connection. Everything you type runs on the server. It's how you'll install software, deploy apps and read logs on a VPS. (What is a VPS?)

What you need

  • The server's IP address or hostname (from your hosting dashboard)
  • A username — often root on a fresh server, or ubuntu, debian, or one you created
  • A way to authenticate: an SSH key (recommended) or a password

Connecting

The command is the same on every system:

ssh username@server-address

For example:

ssh root@203.0.113.10
ssh deploy@myserver.example.com

macOS and Linux

Open Terminal and run the command. SSH is built in.

Windows

Windows 10 and 11 include OpenSSH. Open PowerShell or Windows Terminal and run the same command. (PuTTY also works, but isn't needed any more.)

The first-connection prompt

The first time you connect to a server, you'll see:

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

SSH is asking you to confirm this really is your server. If you can, compare the fingerprint with the one in your provider's console. Type yes. SSH remembers it in ~/.ssh/known_hosts and will warn you loudly if it ever changes.

Password vs SSH key

Password: type it when prompted (nothing appears as you type — that's normal). Simple, but passwords can be guessed by bots that try millions of combinations. (Brute force attacks)

SSH key: a pair of files — a private key that stays on your computer and a public key you put on the server. Far more secure, and no typing passwords. Create one:

ssh-keygen -t ed25519 -C "you@example.com"

Then copy the public key to the server:

ssh-copy-id username@server-address        # macOS / Linux

Most providers also let you paste your public key (~/.ssh/id_ed25519.pub) when creating the server. (SSH keys explained)

Once keys work, disable password logins on the server. (How to secure a new VPS)

A shortcut: the SSH config file

Instead of typing ssh deploy@203.0.113.10 -i ~/.ssh/work_key every time, add to ~/.ssh/config:

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

Now ssh myserver is enough. (The SSH config file explained)

Once you're in

whoami          # which user am I?
hostname        # which machine?
exit            # disconnect (or Ctrl+D)

(Basic Linux commands)

If you start something long-running, use tmux so it survives if your connection drops. (tmux cheat sheet)

Common errors

Connection timed out — the server is off, the IP is wrong, or a firewall is blocking port 22. Check the provider's firewall rules.

Connection refused — the server is reachable but SSH isn't running on that port (or uses a non-standard one: ssh -p 2222 user@host).

Permission denied (publickey) — the server only accepts keys, and yours isn't set up for that user. (Fix it)

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! — the server's identity differs from last time. If you rebuilt the server, that's expected: remove the old entry with ssh-keygen -R 203.0.113.10 and reconnect. If you didn't, stop and investigate. (Man-in-the-middle attacks)

Editing files on the server comfortably

The terminal editor nano is fine for small changes. For real work, VS Code's Remote - SSH extension opens the server's files in your local editor. (VS Code Remote SSH)


EasySpawn gives you SSH access to your server and a terminal in the browser — no keys to juggle if you'd rather not. See how it works or join the waitlist.

Related: SSH Keys Explained · The SSH Config File Explained · How to Secure a New VPS · Basic Linux Commands

Keep reading