Skip to content
# Networking

SSH configuration & key-based auth

Set up SSH key login and harden sshd_config against password brute-forcing.

Generate a key pair (on your own machine)

Ed25519 is the current recommended key type β€” fast and secure. Run this on your laptop, not the server.

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

Copy your public key to the server

ssh-copy-id appends your public key to the server's ~/.ssh/authorized_keys. If you ordered your bashrack VPS with an SSH key already, this step is done for you.

bash
ssh-copy-id root@YOUR_SERVER_IP
# or manually:
cat ~/.ssh/id_ed25519.pub | ssh root@YOUR_SERVER_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Make logins easier: ~/.ssh/config

Define a short alias for a server instead of typing the full IP and options every time.

text
Host myvps
    HostName 203.0.113.10
    User root
    IdentityFile ~/.ssh/id_ed25519

Harden sshd once keys work

Only disable password login after confirming key login actually works β€” test in a second terminal before closing your first session, so you don't lock yourself out.

bash
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
sudo systemctl restart sshd