How to Secure SSH with Key-Based Login
VPS Servers · Self-help guide
SSH keys are more secure than password-only access when used correctly. On your computer, create a key pair with ssh-keygen -t ed25519. Keep the private key safe and never upload it to websites or tickets. Copy the public key to the server using ssh-copy-id username@server-ip. If the SSH port is custom, use ssh-copy-id -p 2222 username@server-ip. Test login with ssh username@server-ip. Once key login works, you may choose to disable password login, but do this carefully. Edit SSH settings only if you understand them, and keep an active session open while testing. Incorrect SSH changes can lock you out of the VPS.