SSH Keys

SSH keys are more secure than passwords and more convenient: no more credential entry at each access.

02

How It Works

You generate a key pair:

  • Private key: stays on your computer (never share)
  • Public key: goes on server
03

1. Generate Key Pair

On Linux / macOS / Windows (PowerShell):

bash
ssh-keygen -t ed25519 -C "my-server-key"

You'll be asked where to save key (press Enter for default ~/.ssh/id_ed25519) and optional passphrase.

04

2. Copy Public Key to Server

bash
ssh-copy-id root@SERVER_IP

If SSH port is different from 22:

bash
ssh-copy-id -p PORT root@SERVER_IP

Manual alternative (if ssh-copy-id not available):

bash
cat ~/.ssh/id_ed25519.pub | ssh root@SERVER_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
05

3. Verify It Works

bash
ssh root@SERVER_IP

If connection works without password, keys are configured correctly.

06

4. Disable Password Access (optional but recommended)

Once verified keys work, disable login via password:

bash
nano /etc/ssh/sshd_config

Find and set:

PasswordAuthentication no PermitRootLogin prohibit-password

Restart SSH:

bash
systemctl restart sshd

Before disabling password access, ensure SSH keys work correctly. Otherwise you risk locking yourself out.

07

Manage Multiple Keys (SSH Config)

If you have multiple servers, create ~/.ssh/config to manage them easily:

Host my-vps HostName SERVER_IP User root Port 22 IdentityFile ~/.ssh/id_ed25519 Host other-server HostName OTHER_SERVER_IP User ubuntu Port 2222 IdentityFile ~/.ssh/id_ed25519

Then access simply with:

bash
ssh my-vps

DeluxHost, opgericht in 2023, biedt hoogwaardige hostingoplossingen voor diverse digitale behoeften. Wij bieden gedeelde hosting, VPS en dedicated servers met geavanceerde beveiliging en wereldwijde datacenters.

© DeluxHost, Alle rechten voorbehouden. | BTW-nummer: IT17734661006
Alle systemen operationeel