August 13, 2026 · by CLIQHOST
Password-based SSH authentication is one of the most common entry points for attackers. Bots continuously scan the internet for open port 22 and attempt thousands of username/password combinations per second (brute-force attacks). The elegant, industry-recommended solution is SSH key authentication — a cryptographic mechanism that is both far more secure and, once configured, more convenient to use.
This guide walks you through the entire process — from generating a key pair to disabling password authentication — applicable to any Linux server, whether a high-performance NVMe VPS or a dedicated machine.
SSH (Secure Shell) supports two primary authentication methods:
The private key can be additionally protected with a local passphrase, adding a second layer of security.
Open a terminal on your machine (Linux, macOS, or WSL on Windows) and run:
ssh-keygen -t ed25519 -C "[email protected]"
Why ed25519? It's the modern recommended algorithm — shorter keys, stronger security than RSA-2048 or RSA-4096. On very old servers, use
ssh-keygen -t rsa -b 4096.
The command will ask for:
1. File location — press Enter to accept the default (~/.ssh/id_ed25519).
2. Passphrase — highly recommended; protects your private key if someone gains access to your computer.
Two files are created:
- ~/.ssh/id_ed25519 — the private key (never share this!)
- ~/.ssh/id_ed25519.pub — the public key (this gets copied to the server)
ssh-copy-id (recommended on Linux/macOS)ssh-copy-id -i ~/.ssh/id_ed25519.pub user@SERVER_IP
This command authenticates with your current password, automatically creates ~/.ssh/authorized_keys, and appends the key.
ssh-copy-id is unavailable)# Display the public key and copy it
cat ~/.ssh/id_ed25519.pub
On the server, as your user:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
# Paste the public key content, save the file
chmod 600 ~/.ssh/authorized_keys
Before disabling password login, open a new terminal window and verify the connection:
ssh -i ~/.ssh/id_ed25519 user@SERVER_IP
If you connected without a password (or using the key's passphrase), everything is working. Do not close your current session until confirmed!
If you're using a SSD VPS at CLIQHOST, find your server IP in the client control panel.
This is the critical step. Edit the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Find and modify (or add) the following directives:
PasswordAuthentication no
PubkeyAuthentication yes
PermitEmptyPasswords no
ChallengeResponseAuthentication no
On Ubuntu 22.04+, also check files in /etc/ssh/sshd_config.d/ — they may override the main settings:
grep -r 'PasswordAuthentication' /etc/ssh/sshd_config.d/
After making changes, restart the SSH service:
sudo systemctl restart sshd
While you're in the file, apply these best practices:
# Disable direct root login
PermitRootLogin no
# Restrict which users can SSH
AllowUsers your_username
# Change the default port (optional, reduces log noise)
Port 2222
# Idle session timeout
ClientAliveInterval 300
ClientAliveCountMax 2
Warning if you change the port: update your firewall rules before restarting, or you'll lock yourself out!
# UFW
sudo ufw allow 2222/tcp
# iptables
sudo iptables -A INPUT -p tcp --dport 2222 -j ACCEPT
For comprehensive firewall and server security management, explore CLIQHOST's server management services.
~/.ssh/config File on Your Local MachineIf you manage multiple servers, create a config file to simplify connections:
# ~/.ssh/config
Host vps-prod
HostName 185.x.x.x
User adminuser
Port 2222
IdentityFile ~/.ssh/id_ed25519
Host vps-dev
HostName 185.x.x.y
User devuser
Port 22
IdentityFile ~/.ssh/id_ed25519_dev
Now you simply connect with:
ssh vps-prod
Generate a new key periodically (annually or when team members leave), add it to authorized_keys, then remove the old one. Never leave unused keys on the server.
On a managed dedicated server where a team operates, each administrator should have their own key pair. Keys are added to authorized_keys one per line:
# authorized_keys — each line = one public key
ssh-ed25519 AAAA...key_admin1... [email protected]
ssh-ed25519 AAAA...key_admin2... [email protected]
When an admin leaves, simply delete their line — no need to reset the entire server's keys.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
authorized_keys with no line breaks.ssh -vvv user@serverrestorecon -Rv ~/.ssh
If you disabled password auth and the key isn't working, access the VPS VNC console in the CLIQHOST control panel, or reach out to our support team — access can be restored at the hypervisor level.
If you set a passphrase on your key (you should!), you don't need to type it every time. SSH Agent keeps it in memory for the duration of the session:
# Start the agent
eval "$(ssh-agent -s)"
# Add your key (enter passphrase once)
ssh-add ~/.ssh/id_ed25519
On macOS, save it to Keychain: ssh-add --apple-use-keychain ~/.ssh/id_ed25519
ed25519~/.ssh/authorized_keys on the serverPasswordAuthentication no set in sshd_configPermitRootLogin no enabledSSH key authentication is one of the most effective security measures you can apply to a Linux server. Setup takes 10–15 minutes and virtually eliminates the risk of brute-force attacks on SSH access.
If you're running a serious project on a high-performance NVMe VPS or a dedicated server, securing SSH access is the first step in a solid security strategy.
Not sure how to configure your server correctly? The CLIQHOST team offers complete Linux server management services — from initial hardening to continuous monitoring. Contact us and we'll set up your server according to security best practices.
Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.
"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."
"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."
"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."