How to Connect to a Linux Server with SSH (From Windows, Mac or Linux)

Nobody sits at a server with a keyboard and monitor. You log in to it over the network from the computer you normally use, type commands, and the server does the work. The tool for that is SSH (Secure Shell), and it's built into Windows, macOS and Linux already.
Quick reference
| What | Command |
|---|---|
| Connect | ssh username@192.168.1.50 |
| Connect on a different port | ssh -p 2222 username@192.168.1.50 |
| Disconnect | exit (or press Ctrl + D) |
| Find the server's IP (on the server) | ip a or hostname -I |
1. Find the server's IP address
On the server itself, type:
hostname -I
You'll get something like 192.168.1.50. If you can't get to the server's screen, look in your router's admin page for a device with the server's name.
2. Connect from Windows
- Press Win + X and choose Terminal (or open PowerShell).
- Type ssh followed by your username, an @, and the IP address:
ssh john@192.168.1.50
- The first time, it asks if you're sure you want to connect. Type yes and press Enter.
- Type your password (nothing shows as you type) and press Enter.
The prompt changes to the server's name. Everything you type now runs on the server.
3. Connect from a Mac or Linux
Open Terminal and use exactly the same command. SSH has been in macOS for years.
4. Disconnect
Type exit and press Enter, or press Ctrl + D. The server keeps running; you've just hung up the call.
Make it easier: a nickname for the server
Typing the IP address every time gets old. Create a file called config in the .ssh folder of your own computer (C:\Users\You.ssh\config on Windows, ~/.ssh/config on Mac/Linux) with:
Host home
HostName 192.168.1.50
User john
Now ssh home is all you need.
Copy and paste in the terminal
- Windows Terminal: right-click pastes. Select text to copy it.
- Mac: Cmd + C and Cmd + V work as normal.
- Linux: Ctrl + Shift + C and Ctrl + Shift + V.
Don't press Ctrl + C in a Linux terminal expecting to copy — it cancels whatever's running.
Troubleshooting
"Connection refused." The SSH server isn't running. On the server, run sudo apt install openssh-server and then sudo systemctl enable --now ssh.
"Connection timed out." Wrong IP address, or the server and your computer are on different networks. Check both with hostname -I and make sure they share the first three numbers.
"Permission denied." Wrong password or wrong username. Linux usernames are case-sensitive and were set during installation.
"Remote host identification has changed." You reinstalled the server and it has a new identity. Open ~/.ssh/known_hosts on your computer, delete the line with the server's IP, and connect again.
It works at home but not away. SSH only reaches the server on your local network. For access from outside, set up a VPN (tutorial later in this series) rather than opening SSH to the internet.
Wrapping up
ssh user@address, say yes once, type your password. That one command is how you'll do everything else in this series, so take a minute to set up the nickname in your config file. The next tutorial replaces passwords with keys, which is both more secure and less typing.
