You'll create an SSH key, upload it to your VPS and log in without a password. Finally you'll turn off password login, so guessing passwords becomes pointless. The steps cover Windows, macOS, Linux and PuTTY.
What you'll need
- A StormHost VPS with Ubuntu 24.04 or Debian 13
- A working SSH connection with a password (guide)
- A computer with Windows 10/11, macOS or Linux
- About 15 minutes
How an SSH key works#
An SSH key consists of two files that belong together:
| File | Example name | Where it lives | Who to give it to |
|---|---|---|---|
| Private key | id_ed25519 (PuTTY: .ppk) | Only on your computer. | Nobody. Whoever has it can log in as you. |
| Public key | id_ed25519.pub | On the VPS in the file ~/.ssh/authorized_keys. | You can put it anywhere; it can't be misused. |
When you log in, the VPS sends your computer a challenge that only the holder of the private key can solve. The private key never leaves your computer. An ed25519 key is modern, short and secure, and all current systems support it.
You can also lock the private key with a key password (passphrase). If someone copies your key file, they can't use it without this password.
Creating a key#
Windows
Open Terminal (right-click Start › Terminal; in Windows 10 Windows PowerShell).
Run:
PowerShell ssh-keygen -t ed25519 -C "notebook-jan"At the question
Enter file in which to save the key (C:\press Enter. The key is saved to the default location, where SSH finds it by itself.Users\ jan/ .ssh/ id_ ed25519): At
Enter passphrase, enter a key password and press Enter. AtEnter same passphrase again, repeat it. The password doesn't show. If you leave it empty, the key won't be locked.
Result: the files C:\ (private) and id_ed25519.pub (public).
macOS
Open the Terminal app.
Run:
bash ssh-keygen -t ed25519 -C "macbook-jan"At the question
Enter file in which to save the key, press Enter.Enter and repeat the key password (passphrase).
Result: ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519.pub.
Linux
Open a terminal.
Run:
bash ssh-keygen -t ed25519 -C "pc-jan"At the question
Enter file in which to save the key, press Enter.Enter and repeat the key password (passphrase).
Result: ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519.pub.
What the command does:
ssh-keygen– a program for creating SSH keys.-t ed25519– the key type. We recommend Ed25519. Use the older RSA type only for devices that can't do ed25519, and then with the length-t rsa -b 4096.-C "notebook-jan"– a label (comment) at the end of the public key. It tells you on the VPS which computer the key is from. The label doesn't secure anything; it's just for orientation.
Already have a key?
When ssh-keygen says … already exists. Overwrite (y/n)?, answer n. Overwriting would lose your old key and your access everywhere you use it. Feel free to use the old key for the VPS too.
Creating a key in PuTTYgen#
If you connect with PuTTY, create the key in PuTTYgen, which is installed together with PuTTY.
- Start PuTTYgen.
- Under Parameters, choose the type EdDSA and next to it Ed25519 (255 bits).
- Click Generate and move the mouse over the empty area of the window until the progress bar fills up. The mouse movement serves as a source of randomness.
- In the Key comment field, type a label, for example
notebook-jan. - In the Key passphrase and Confirm passphrase fields, enter a key password.
- Click Save private key and save the file, for example
C:\. This is the private key.Users\ <USER>\ .ssh\ vps. ppk - Select and copy all the text in the Public key for pasting into OpenSSH authorized_keys file field. It starts with
ssh-ed25519 AAAA…and ends with the label. This is the public key, which you upload to the VPS by hand (see the Manually tab below).
The Save public key button saves the public key in a different format that the VPS won't accept. Always copy the text from the field.
Uploading the public key to the VPS#
Windows
Windows doesn't have the ssh-copy-id command. This PowerShell command does the same job (replace 203.0.113.10 with your VPS IP address):
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"type $env:– prints the contents of the public key (USERPROFILE\ .ssh\ id_ ed25519. pub $env:USERPROFILEis yourC:\Users\<USER>folder).|– passes the output as input to the next command.ssh [email protected] "…"– connects to the VPS (asks for the root password) and runs the commands in quotes.mkdir -p ~/.ssh– creates the.sshfolder if it doesn't exist yet.chmod 700 ~/.ssh– only the owner can open the folder. SSH rejects permissions that are too open.cat >> ~/.ssh/authorized_keys– appends the key to the end of the file. Keys already there stay.chmod 600 ~/.ssh/authorized_keys– only the owner can read and change the file.
macOS
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]ssh-copy-id– uploads the public key to the server and sets the right permissions.-i ~/.ssh/id_ed25519.pub– which key to upload.[email protected]– the user and address of the VPS.
It asks for the root password and finally prints Number of key(s) added: 1.
Linux
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]ssh-copy-id– uploads the public key to the server and sets the right permissions.-i ~/.ssh/id_ed25519.pub– which key to upload.
It asks for the root password and finally prints Number of key(s) added: 1.
Manually
Useful for a key from PuTTYgen or when the previous methods don't work for you.
Connect to the VPS with a password (PuTTY, a terminal or the browser console).
Prepare the folder and open the keys file:
bash mkdir -p ~/.ssh && chmod 700 ~/.ssh nano ~/.ssh/authorized_keysPaste the public key on a line of its own (in PuTTY with a right-click). The whole key must be on one line:
ssh-ed25519 AAAA… comment.Save (Ctrl+O, Enter) and close the editor (Ctrl+X).
Set the permissions:
bash chmod 600 ~/.ssh/authorized_keys
Logging in with the key#
The SSH client finds a key in the default location (id_ed25519) by itself, so the usual command is enough:
ssh [email protected]If you set a password for the key, the client asks Enter passphrase for key. You enter the key password, not the root password.
You specify a key stored elsewhere or under a different name with the -i option:
ssh -i ~/.ssh/vps_klic [email protected]-i ~/.ssh/vps_klic– the path to the private key (the file without.pub).
PuTTY:
- Start PuTTY and load the saved session (Load), or fill in the IP address.
- In the tree on the left, open Connection › SSH › Auth › Credentials.
- Next to the Private key file for authentication field, click Browse and choose the
.ppkfile. - Optional: under Connection › Data, fill in Auto-login username with
root. - Go back to Session, click the session name and Save, so you don't have to set this up next time.
- Click Open.
You can use a key from ssh-keygen in PuTTY too: in PuTTYgen click Load, choose the id_ed25519 file (switch the file filter to All Files) and save it with Save private key as .ppk. The other way round, you convert a PuTTYgen key to the OpenSSH format with Conversions › Export OpenSSH key.
ssh-agent: enter the key password only once#
ssh-agent remembers the unlocked key, so you don't enter the key password on every connection.
Windows
In PowerShell run as administrator, turn on the agent service (it's off by default):
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agentSet-Service -StartupType Automatic– the agent starts with the system.Start-Service ssh-agent– starts the agent now.
Then add the key in a regular window (it asks for the key password):
ssh-add $env:USERPROFILE\.ssh\id_ed25519macOS
ssh-add --apple-use-keychain ~/.ssh/id_ed25519--apple-use-keychain– saves the key password to the macOS Keychain.
To have SSH use the password from Keychain automatically even after the Mac restarts, add this to the beginning of the ~/.ssh/config file (see the next section):
Host *
UseKeychain yes
AddKeysToAgent yesUseKeychain yes– the key password is loaded from Keychain (macOS only).AddKeysToAgent yes– the unlocked key is added to the agent the first time it's used.
Linux
Most desktop environments start the agent by themselves. Add the key with:
ssh-add ~/.ssh/id_ed25519To check: ssh-add -l lists the fingerprints of the keys the agent has loaded.
The ~/.ssh/config file: connect with one word#
Save your VPS settings in the config file in the .ssh folder (Windows: C:\, no extension):
Host mojevps
HostName 203.0.113.10
User root
Port 22
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes| Directive | What it does |
|---|---|
Host mojevps | The shortcut you'll type instead of the address. Applies to the lines below it. |
HostName | The real IP address or domain of the VPS. |
User | The user you log in as. |
Port | The SSH port. Change it if you moved SSH to a different port. |
IdentityFile | The private key for this VPS. |
IdentitiesOnly yes | Try only the key from IdentityFile, not all keys from the agent. Prevents the Too many authentication failures error. |
Then you connect with ssh mojevps. scp and sftp use the shortcut too.
Turning off password login#
As long as password login is on, bots can keep trying it. Once it's off, the VPS accepts only a key.
What turning off passwords affects in the customer area
The Files and Database tabs log in to the VPS with a password. Once passwords are off, they stop working. Then transfer files with an SFTP client using your key (both WinSCP and FileZilla support keys) and manage the database through an SSH tunnel. The browser console keeps working. An overview of all the effects is in the Securing a new VPS guide.
First check that key login works
If you turn off passwords and the key doesn't work, you won't be able to log in over SSH. Before you continue, open a new window and log in with the key without entering the root password. Keep the original window open the whole time. If something still goes wrong, log in through the browser console with the root password and delete the file from step 1.
Create (or open) your own SSH server configuration file:
bash nano /etc/ssh/sshd_config.d/00-zabezpeceni.confPaste the settings:
/etc/ ssh/ inisshd_config.d/ 00-zabezpeceni.conf PasswordAuthentication no KbdInteractiveAuthentication no PubkeyAuthentication yes PermitRootLogin prohibit-passwordIf the file already has
PermitRootLogin no(from the Securing a new VPS guide), leave out the last line.Setting What it does Recommended value When to change PasswordAuthenticationAllows password login. noNever, if you want passwords off. KbdInteractiveAuthenticationAnother way of entering a password (an interactive prompt). Even with PasswordAuthenticationoff, a password could be entered through it.noyesonly for two-factor authentication through PAM (advanced).PubkeyAuthenticationAllows key login. The default value is yes; we list it to be safe.yesNever. PermitRootLoginRoot login. prohibit-password= root only with a key.prohibit-passwordno, if you work under your own user withsudo.Save and close the editor.
Check that exactly your values apply:
bash sshd -t && sshd -T | grep -Ei "^(passwordauthentication|kbdinteractiveauthentication|pubkeyauthentication|permitrootlogin)"sshd -t– checks the configuration syntax. On an error it prints the file and line, and the next command doesn't run.sshd -T– prints the resulting effective configuration after loading all files.grep -Ei "…"– picks out only the four settings you're checking.
The output must contain these four lines (the order may differ):
Outputtext permitrootlogin without-password pubkeyauthentication yes passwordauthentication no kbdinteractiveauthentication nowithout-passwordis the older name forprohibit-passwordand means the same. Ubuntu 24.04 and Debian 13 print the older name; newer OpenSSH versions printprohibit-password. If you setno, you'll seepermitrootlogin no.If any line shows a different value (typically
passwordauthentication yes), the same setting is in a file that loads earlier. Find it withgrep -rni "passwordauthentication" /etc/ssh/sshd_config.d/. Comment out the line there with a#at the beginning and repeat the check.Restart the SSH server:
bash systemctl restart sshThe current connection stays open.
In a new window, try to force a password login:
bash ssh -o PubkeyAuthentication=no [email protected]The server must reply
Permission denied (publickey).That's correct: it no longer accepts passwords.In another window, log in normally with the key (
ssh [email protected]). Only when that works, close the original window.
Why the 00-zabezpeceni.conf file
The SSH server first reads the files in the /etc/ssh/sshd_config.d/ folder (in alphabetical order) and then the main /etc/ssh/sshd_config. For each setting, the first value found applies. The VPS may have a file like 50-cloud-init.conf with PasswordAuthentication yes. Thanks to the number 00, your file loads first and its values win. The sshd -T check always confirms this for you.
Multiple computers, removing and backing up a key#
- Another computer: create its own key with a different label and upload it the same way. Each key is on a separate line in
~/.ssh/authorized_keys. We don't recommend copying one private key between computers. - Removing a key (a lost laptop, a colleague leaving): open
nano ~/.ssh/authorized_keysand delete the line with its label. It takes effect immediately. - Backup: store the private key in a password manager or on encrypted storage. If you lose it and have passwords turned off, log in through the browser console and upload a new public key.
- A user other than root: the key goes in
/home/and that user must own the file.<USER>/ .ssh/ authorized_ keys
Verification#
ssh root@<VPS_IP_ADDRESS>logs you in without the root password (at most it asks for the key password).ssh -o PubkeyAuthentication=no root@<VPS_IP_ADDRESS>ends withPermission denied (publickey).sshd -Tshowspasswordauthentication no.
Troubleshooting#
The VPS still asks for the root password#
The key wasn't used. Connect with verbose output:
ssh -v [email protected]-v– verbose output. Look for the linesOffering public key(the client offered the key) andServer accepts key(the server accepted it).
If the client doesn't offer the key, it's in a different file: use -i or IdentityFile. If the server doesn't accept it, check the permissions on the VPS:
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
journalctl -u ssh -n 30journalctl -u ssh -n 30– the last 30 SSH server entries. The messageAuthentication refused: bad ownership or modesmeans wrong permissions or a wrong owner of the.sshfolder.
Also check that the key in authorized_keys is on one line and starts with ssh-ed25519.
Permission denied (publickey).#
Passwords are off and the server didn't accept the key. Proceed as in the previous point. If you can't log in at all, use the browser console.
Windows: WARNING: UNPROTECTED PRIVATE KEY FILE! or Bad permissions#
Other users of the computer also have access to the private key (typically after copying it from somewhere else) and the client refuses to use it. Set the permissions in PowerShell:
icacls $env:USERPROFILE\.ssh\id_ed25519 /inheritance:r
icacls $env:USERPROFILE\.ssh\id_ed25519 /grant:r "$($env:USERNAME):(R)"/inheritance:r– removes the permissions inherited from the folder./grant:r "<USER>:(R)"– gives only your account permission to read.
On macOS and Linux you fix the same error with chmod 600 ~/.ssh/id_ed25519.
Load key "…": invalid format#
You're trying to use a key in PuTTY format (.ppk) with OpenSSH. Convert it in PuTTYgen with Conversions › Export OpenSSH key.
PuTTY: Server refused our key#
The right public key isn't on the VPS. Copy the text from the Public key for pasting into OpenSSH authorized_keys file field again (not the file from Save public key) and paste it into ~/.ssh/authorized_keys on one line.
Too many authentication failures#
The agent offers too many keys. Use IdentitiesOnly yes in ~/.ssh/config, or the options -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes.
Summary
- The private key stays only on your computer; the public key goes in
~/.ssh/authorized_keyson the VPS. - Create the key with
ssh-keygen -t ed25519 -C "comment"or in PuTTYgen (EdDSA, Ed25519). - Uploading:
ssh-copy-id(macOS, Linux), on Windowstype … | ssh …, or by hand. - Turn off passwords with the file
/etc/and verify the result withssh/ sshd_ config. d/ 00-zabezpeceni. conf sshd -T. - Before closing the original window, always test key login in a new window.
- Turning off passwords also disables the Files and Database tabs; the console keeps working.