SSH keys provide a secure alternative to password-based authentication. Once a public key is added to your hosting account, you can connect via SSH using the corresponding private key stored on your device.
To complete the next steps, you must have active access to SSH. Click HERE to learn how.
Table of Contents
Step 1: Connect to the Server
Log in to your hosting account using SSH.
Step 2: Open the Authorized Keys File
In the terminal, run the following command:
nano ~/.ssh/authorized_keys If the file does not exist, it will be created automatically when saved.
Step 3: Add Your Public SSH Key
Paste your public SSH key on a new line in the file.
A public key typically looks similar to:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ... Make sure the entire key is pasted on a single line without any additional characters or formatting.
If you have not yet generated an SSH key pair, first create one on your local computer and then copy the public key to the server.
Step 4: Save the File
To save the changes in Nano:
- Press Ctrl + X
- Press Y to confirm the changes
- Press Enter to save the file
Step 5: Test the Connection
After saving the file, try connecting to the server using the private key associated with the public key you added.
If the key has been configured correctly, you should be able to authenticate without entering your account password.
Security Recommendations
- Never share your private SSH key.
- Store your private key securely on trusted devices.
- Remove unused keys from the
authorized_keysfile. - Use a passphrase to protect your private key whenever possible.
Summary
To add an SSH key to your hosting account, connect to the server, open the ~/.ssh/authorized_keys file, paste your public key on a new line, and save the changes. Once configured, you can use key-based authentication to access your account via SSH.