Skip to main content

๐Ÿ” Set Up SSH Key Authentication

Using SSH keys is more secure than password-based login.


๐Ÿ›  Step 1: Generate an SSH Key (Local Machine)โ€‹

ssh-keygen -t ed25519 -C "[email protected]"

Press Enter to accept defaults. This creates:

  • ~/.ssh/id_ed25519 (private key)
  • ~/.ssh/id_ed25519.pub (public key)

๐Ÿ“ค Step 2: Copy Public Key to VPSโ€‹

ssh-copy-id yourusername@your_vps_ip

OR manually copy the .pub contents into:

~/.ssh/authorized_keys

๐Ÿงช Step 3: Test SSH Key Loginโ€‹

In a separate terminal, test:

ssh yourusername@your_vps_ip

You should log in without a password.


๐Ÿšซ Step 4: Disable Password Authenticationโ€‹

Once key-based login works, disable password auth:

sudo nano /etc/ssh/sshd_config

Find and edit:

PasswordAuthentication no

Save and restart:

sudo systemctl restart ssh

โœ… Your server now only allows SSH access using your key.

ยฉ 2025 TokioStack. All rights reserved.
DMCA.com Protection Status