Set up SSH keys
Create an SSH key pair, add it to your Linux VPS from macOS, Linux or Windows, and optionally switch off password logins safely.
- Intermediate
- Linux VPS
- 2 min read
SSH keys replace passwords with a key pair. The private key stays on your computer and the public key goes on the server. Keys are far harder to guess than any password, and once they are set up you log in without typing one.
1. Create a key pair on your computer
macOS, Linux and Windows 10 or 11 (PowerShell) all include OpenSSH. Run:
ssh-keygen -t ed25519 -C "you@laptop"Press Enter to accept the default file location. When asked, set a passphrase. It protects the key if your computer is ever stolen.
This creates two files in the .ssh folder in your home directory:
id_ed25519is the private key. Never share it or upload it anywhere.id_ed25519.pubis the public key. This one is safe to copy to servers.
2. Copy the public key to your server
On macOS and Linux:
ssh-copy-id [email protected]On Windows PowerShell, which has no ssh-copy-id:
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"Enter the server password one last time.
3. Test the key
ssh [email protected]You should be asked for your key's passphrase, if you set one, and not the server password.
4. Turn off password logins (optional)
Keep your current SSH session open while you do this, and test from a second terminal before you close it. If something goes wrong, use the browser console in the control panel to undo the change.
Open the SSH server configuration:
nano /etc/ssh/sshd_configSet this line (remove the # in front if there is one):
PasswordAuthentication noSome images also set this option in a file under /etc/ssh/sshd_config.d/, and that file can override your change. Check with:
grep -ri passwordauthentication /etc/ssh/sshd_config.d/Check the configuration for mistakes, then reload SSH. On Debian and Ubuntu the service is called ssh. On RHEL-based systems it is sshd.
sshd -t && systemctl reload sshUsing more than one computer
Create a separate key on each device and add each public key as its own line in ~/.ssh/authorized_keys. If you lose a device, delete only that line.
Was this guide helpful?
Still stuck?
Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.
Related guides
Security
Check the Windows Firewall rule for RDP port 12230
Find and verify the inbound TCP 12230 rule that lets Remote Desktop reach your RunRacks server, recreate it if it was deleted and scope it without locking yourself out.
- Intermediate
- Windows VPS · Admin RDP
- 5 min read
Security
Linux Security: Using aide for File Integrity Monitoring on VPS
AIDE builds a checksum database of your system files and reports anything that changed. This guide installs it, creates a baseline, tunes the rules and schedules daily checks on a Linux VPS.
- Advanced
- Linux VPS
- 6 min read
Security
iptables basics: list, allow, drop and save rules
Learn how iptables chains and rule order work, then build a small ruleset that allows SSH and web traffic, drops everything else and can be edited by line number.
- Intermediate
- Linux VPS
- 6 min read