How to add a public SSH key to your server

Step-by-step guide to adding a public SSH key for secure server access.

SH key authentication is the most secure way to connect to your VPS or dedicated server. The public key is placed on the server, while the private key stays safely on your computer — this completely eliminates password interception and significantly improves security.

Method 1: Adding the key via Fornex dashboard (recommended)

  1. Log in to your Fornex personal dashboard and select the desired order.
  2. Go to the SSH Access section.
  3. Click Manage SSH KeysAdd SSH Key.

Manage VPS order Manage VPS order

  1. Paste your copied public key and give it a name.

VPS SSH-key management VPS SSH-key management

  1. Click Save.

SSH-key automatically adding SSH-key automatically adding

SSH key settings will be applied only after OS reinstallation.

Method 2: Manually copying the public key to the server

  1. Connect to the server via SSH (using password for now):
ssh root@your_server_ip
  1. Create the .ssh folder if it doesn’t exist:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
  1. Add the public key to authorized_keys:
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your_email@example.com" >> ~/.ssh/authorized_keys

Recommended one-command method from your local machine:

ssh-copy-id -i ~/.ssh/id_ed25519.pub root@your_server_ip

Configure the OpenSSH Server

  1. Open the SSH server configuration file:
nano /etc/ssh/sshd_config
  1. Make sure the following settings are present (uncomment or add them):
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PasswordAuthentication no          # Recommended: disable password login
  1. Save the file (Ctrl+O → Enter → Ctrl+X).
  2. Set correct permissions on the files:
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chown root:root ~/.ssh/authorized_keys
  1. Restart the SSH service:
systemctl restart sshd

Help

If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!

Need help?Our engineers will help you free of charge with any question in minutesContact us