Guides / SSH keys
Log in with SSH keys
Bots try passwords on every SSH port they find. A key is much harder to guess and saves you typing the password.
1. Create a key on your computer
ssh-keygen -t ed25519
Press Enter to accept the default file. A passphrase is optional but recommended. This works in Terminal on macOS and Linux and in PowerShell on Windows.
2. Copy it to your server
ssh-copy-id -p 10000 root@natbox.io
Use your own SSH port. On Windows, where ssh-copy-id is missing:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh -p 10000 root@natbox.io "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Log in again with ssh -p 10000 root@natbox.io: no password should be asked.
3. Turn off password logins
echo "PasswordAuthentication no" > /etc/ssh/sshd_config.d/10-keys-only.conf
systemctl restart ssh 2>/dev/null || systemctl restart sshd 2>/dev/null || rc-service sshd restart
Keep your current session open and test a new login in a second window before you close it.
After this, Reset password in the client area can no longer get you in over SSH, because passwords are off. Keep a copy of your key somewhere safe. If you lose it, you can still reinstall from the client area (this deletes the server's data).
4. Shorter logins (optional)
Add this to ~/.ssh/config on your computer, then just type ssh natbox:
Host natbox
HostName natbox.io
Port 10000
User root