SSH into a VPS and create an SSH key on
Windows,
Mac and
Linux
Connect to a server over SSH, make an ed25519 key and fix Permission denied, step by step
On this page
The command to reach a server is ssh username@IP, and it works out of the box on Windows 10/11, macOS and Linux. This guide takes you through your first sign-in, moves you from a password to a key, and fixes the errors people hit most.
Type your own values and the commands on this page follow
Your first sign-in#
Open PowerShell (Windows) or Terminal (macOS, Linux) and type
ssh SERVER_USER@SERVER_IPThe first time, SSH asks you to confirm the server's fingerprint. Type yes, then enter the password. Nothing shows on screen while you type it, and that is normal.
Create an SSH key#
A key is two files. The private file stays on your computer only; the .pub file is the one you put on servers.
ssh-keygen -t ed25519 -C "my-laptop"Press Enter to keep the default location, and set a passphrase so nobody else can use the key if the file ever leaks.
Put the key on the server#
macOS / Linux
ssh-copy-id -i ~/.ssh/id_ed25519.pub SERVER_USER@SERVER_IPWindows PowerShell
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | ssh SERVER_USER@SERVER_IP "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"If you haven't created the server yet, skip this step: add the key on the Cloud Server create page, under SSH keys.
Set a short name#
Edit ~/.ssh/config on your computer, then connect with ssh web1.
Host web1
HostName SERVER_IP
User SERVER_USER
IdentityFile ~/.ssh/id_ed25519Common errors#
| Message | What it means | Fix |
|---|---|---|
Connection timed out |
Nothing reaches port 22 | Check the IP, that the server is running, and the Security Group |
Connection refused |
The server answers but SSH isn't running | Open the web console and check systemctl status ssh |
Permission denied (publickey) |
Wrong key or wrong username | Run ssh -v, check the username and the key file's permissions |
REMOTE HOST IDENTIFICATION HAS CHANGED |
The server's own key changed | If you just reinstalled the server, run ssh-keygen -R SERVER_IP. If you didn't, stop and find out why first |
FAQ#
Do I need PuTTY on
Windows?
No. Windows 10 and 11 ship OpenSSH, which you use from PowerShell. If it's missing, add it under Settings, Optional features.
Should I use ed25519 or RSA?
Use ed25519: the keys are short and every current OpenSSH supports them. Use RSA 4096 only when you must connect to an old system.
I forgot the password and lost the key. Can I still get in?
Yes. If the server has a password, press Reset password on the Access tab to set a new one, sign in with it and add a new key. If you chose an SSH key when you created the server, it has no password: create a new key pair, add the public key on the SSH Keys page of your account, then press Add an SSH key to this server on the Access tab, pick the key and confirm it is you. The key is added without you having to sign in first, and existing keys keep working. Either way the server must be running. If it still fails, open a support ticket before you delete the server, and always keep a backup of your private key file.
Next step: secure your Ubuntu server before it goes live.