Adding an SSH public key to your Linux VPS improves security by reducing the risk of password-based attacks such as brute-force attempts. It also simplifies server administration, particularly if you regularly connect to your VPS or automate deployment and maintenance tasks.
Secure Shell (SSH) is the standard method of securely accessing and managing a Linux Virtual Private Server (VPS). While SSH supports password-based authentication, using SSH keys provides a more secure and convenient way to login to your server. SSH key authentication uses a pair of cryptographic keys (a private key stored securely on your computer and a public key installed on the VPS) to verify your identity without transmitting your password over the network.
Before you can use SSH key authentication, you must generate an SSH key pair on your local computer and add the public key to your Linux VPS.
This guide explains how to add an SSH public key to your Linux VPS.
IMPORTANT:
Never share your private SSH key. Only the public key should be copied to your server.
TABLE OF CONTENTS
Before You Begin
Before adding an SSH public key, ensure that:
- You have access to the Domains.co.za Customer Portal.
- Your Linux VPS has been provisioned successfully.
- You have your VPS IP address.
- You can currently connect to your VPS using SSH.
- You have already generated an SSH key pair on your computer.
How to Add an SSH Public Key to a Linux VPS Hosting
Step 1: Connect to Your VPS Using SSH
- Open your preferred SSH client and connect to your server using your existing credentials.
- For example:
- ssh root@your-server-ip
- Replace your-server-ip with your VPS IP address.
Step 2: Create the SSH Directory (If Required)
- If the .ssh directory does not already exist in your user account, create it using:
- mkdir -p ~/.ssh
- Then set the correct permissions:
- chmod 700 ~/.ssh
Step 3: Add Your Public Key
- Open or create the authorized_keys file:
- nano ~/.ssh/authorized_keys
- Copy and paste your SSH public key into the file.
- Ensure the entire key appears on a single line without any additional spaces or line breaks.
- Save the file and exit the editor.
Step 4: Set File Permissions
- Set the correct permissions on the authorised keys file:
- chmod 600 ~/.ssh/authorized_keys
- Proper permissions help prevent unauthorised access and allow SSH authentication to function correctly.
Step 5: Test the SSH Key
Open a new SSH session using your private key.
- If authentication succeeds without requesting your password, the SSH key has been configured successfully.
- After confirming that key-based authentication works correctly, you may optionally disable password authentication to improve server security.
Troubleshooting
- Permission Denied (Public Key): Verify that the public key has been copied correctly and that the .ssh directory and authorised_keys file have the correct permissions.
- SSH Still Requests a Password: Ensure that your SSH client is using the correct private key and that the corresponding public key has been installed on the server.
- The Public Key Was Copied Incorrectly: The entire key must appear on a single line. Remove any unwanted spaces or line breaks before saving the file.
- I Cannot Connect After Disabling Password Authentication: Reconnect using your configured private key. If key authentication has not been configured correctly, you may need to re-enable password authentication through the VPS console.
Additional Information
- SSH key authentication provides stronger security than password-based logins.
- Your private SSH key should always remain securely stored on your local computer and should never be shared.
- The public key can safely be copied to any Linux server where you require access.
- File and directory permissions are essential for SSH key authentication to function correctly.
- Separate SSH key pairs can be created for different users or devices to improve security management.
- Disabling password authentication after confirming that SSH keys work correctly can further reduce the risk of unauthorised access.
- If you experience issues configuring SSH keys, contact the Domains.co.za Support team for assistance.
Login to Domains.co.za Account
1. Go to the Domains.co.za website Account Login page.

2. Enter your Email and Password and click the Sign In button.
3. You will see the Domains.co.za Dashboard, displaying the Manage Account menu on the left and your Account Information, Account Overview and Open Support Tickets on the right.




