How to SSH into a server from Windows, macOS or Linux
Last changed . CortexHosting is not open yet, so you can’t order a server today.
To SSH into a server, open a terminal on your computer and type ssh, your user name, @ and the server's address:
ssh myuser@203.0.113.10
This works in Windows 10 and 11, macOS and Linux. You don't need to install anything on most computers.
What you need
- The server's IP address or name.
- A user name on that server.
- An SSH key that the server knows, or a password if the server allows them.
Connect
- Open a terminal. On Windows, use PowerShell. On macOS, use Terminal.
- Type the command above, with your own user name and address.
- The first time, SSH asks if you trust this server. Type
yes. - You are in when you see the server's prompt. Type
exitto leave.
Make an SSH key
A key is safer than a password, and you don't have to type it each time. These commands work on all three systems:
ssh-keygen -t ed25519
Press Enter to save it in the normal place. You can add a passphrase, which protects the key if someone copies it.
This makes two files. The one ending in .pub is your public key, and it is safe to share. The other one is your private key. Never share it or send it to anyone.
Show your public key so you can copy it:
| Your computer | Command |
|---|---|
| Windows (PowerShell) | Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub |
| macOS or Linux | cat ~/.ssh/id_ed25519.pub |
To add the key to a server you can already log in to, put that one line at the end of ~/.ssh/authorized_keys on the server.
When it does not work
| What you see | What it means | What to do |
|---|---|---|
Permission denied (publickey), sometimes with more words in the brackets | The server doesn't accept your key for this user | Check the user name. Check that your public key is on the server |
Connection timed out | Your computer can't reach the server | Check the address. Check that the server's firewall allows port 22 |
Connection refused | The server answered, but SSH is not listening on that port | Check that SSH is running. Your server may use another port. Use ssh -p 2222 myuser@203.0.113.10 to try one |
REMOTE HOST IDENTIFICATION HAS CHANGED | The server's identity is not the one your computer remembers | This is normal if you just reinstalled the server. If you didn't, stop and find out why. Then run ssh-keygen -R 203.0.113.10 |
UNPROTECTED PRIVATE KEY FILE | Other people on your computer can read your key | On macOS or Linux, run chmod 600 ~/.ssh/id_ed25519 |
| The key is on the server, but it still asks for a password | The server may be ignoring the key because of its file permissions | On the server, run chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys |
Restart SSH on the server
If you have another way in, such as a web terminal, you can check SSH there. Its name depends on the system:
| System | Check it | Restart it |
|---|---|---|
| Ubuntu or Debian | sudo systemctl status ssh | sudo systemctl restart ssh |
| Rocky Linux, AlmaLinux or RHEL | sudo systemctl status sshd | sudo systemctl restart sshd |
Doing this on CortexHosting
- Add your public key in Settings, under SSH keys. Press Add an SSH key.
- Pick the key when you make a new server. For a server you already have, open it and go to SSH keys.
Connect with the user name
cortex:ssh cortex@your-server-address
Logging in as root is switched off on servers we run. On a VPS, cortex can use sudo to do anything root can do. On a Managed server, no account has sudo.
Don't have a key, or can't get in? Open your server and go to Console. It gives you a terminal in your browser.