8 Aug 2025
If you're using a VPS, the safest way to log in is not with a password — it's with SSH keys.
In this guide, you'll learn how to create an SSH key on Linux, and how to use it to securely access your VPS (for example, from nanohost.org, where VPS plans start at just $8/month).
No prior experience required.
An SSH key is a pair of files used to authenticate with a server. It consists of:
When you try to log in, your VPS checks the public key, and if it matches your private key, access is granted — no password needed.
Open your Terminal and run: ssh-keygen
You’ll see something like:
Just press Enter to accept the default location.
➕ You’ll then be asked:
Enter passphrase (empty for no passphrase):
This is optional. If you want extra security, type a passphrase.
Otherwise, press Enter twice to skip.
🎉 Done! Your SSH key pair is now created.
Your keys are saved in the ~/.ssh
folder:
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
Never share your private key!
Assuming your VPS IP is 45.12.34.56 and your username is root:
ssh-copy-id root@45.12.34.56
You’ll be asked to enter your VPS password once. After that, your key will be uploaded.
Don’t have ssh-copy-id
? Use this:
cat ~/.ssh/id_rsa.pub | ssh root@45.12.34.56 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Now try logging in:
ssh root@45.12.34.56
If everything worked, you’ll be logged in without a password!
To force key-only logins, edit the SSH config on your server: nano /etc/ssh/sshd_config
Find or add these lines:
PasswordAuthentication no
PermitRootLogin prohibit-password
Then restart SSH:
systemctl restart ssh
⚠️ Only do this if you're sure your key works! Otherwise, you may lock yourself out.
Looking to set up your own server?
At nanohost.org, you get:
Perfect for running proxies, apps, or learning Linux.
Secure your server the right way! Learn how to generate and use SSH keys on Linux — a simple step-by-step guide for beginners.
New to VPS hosting? Learn how to connect to your server via SSH in under 5 minutes — step-by-step for beginners.
Need more privacy online or want to access content from another region? A SOCKS5 proxy is a simple way to route your internet traffic through a remote server. In this guide, we’ll show you how to create your own SOCKS5 proxy using a VPS and Docker — even if you’re not a technical expert.