How to Create and Use an SSH Key for a VPS

Updated · Autdo Cloud

Generate an SSH key on your own computer, keep the private key secret and provide only the public key when configuring the VPS. An Ed25519 key is a common choice for current OpenSSH clients and servers.

Generate a separate key

ssh-keygen -t ed25519 -f ~/.ssh/autdo_vps -C "autdo-vps"
sh

Choose a passphrase when prompted and do not overwrite an existing key unintentionally. The file autdo_vps is private; autdo_vps.pub is public. Keep a protected recovery copy of the private key appropriate to your security needs.

Add the public key through the image or instance workflow where supported. If adding it manually to an existing account, use its ~/.ssh/authorized_keys file and the correct owner. Standard permissions are 700 for .ssh and 600 for authorized_keys.

Connect through the assigned NAT port

ssh -i ~/.ssh/autdo_vps -p PUBLIC_PORT USER@PUBLIC_HOST
sh

Replace the uppercase placeholders and confirm the image's login username. Your private key remains on the client; the server verifies possession without needing a copy of it.

Test before restricting access

Keep the current session open and make a fresh connection using the new key. Only then consider disabling password login, after confirming recovery options and that all administrators have suitable access.

If authentication fails, inspect ssh -vv locally and check the server's SSH logs through existing access. Never send the private key, passphrase or unredacted session credentials to support.

See connecting to NAT SSH and safe administrator accounts.

Reference: OpenSSH ssh-keygen manual.