How to Connect to a Self-Managed VPS or VDS Using an SSH Key
After adding an SSH public key to your self-managed VPS or Virtual Dedicated Server (VDS), you can connect to your VPS via SSH using the matching private key.
SSH (Secure Shell) creates an encrypted connection between your computer and server, allowing you to manage your VPS or VDS from the command line.
Before You Begin
Make sure you have the following:
- A Bluehost Self-Managed VPS or VDS.
- Your server's public IP address.
- An SSH key pair.
- The matching private key saved on your computer.
- An SSH client, such as Terminal, PowerShell, or Windows Terminal.
If you have not added your SSH public key yet, see How to Add an SSH Key on a Self-Managed VPS and VDS.
Connect to Your VPS or VDS Using SSH
The SSH command you use depends on your operating system and the location of your private key.
Linux and macOS
- Open Terminal.
- Run the following command:
Replace
your_server_ipwith your actual server IP address.ssh -i /path/to/private-key root@your_server_ip
Replace the following:
/path/to/private-keywith the location of your private SSH key.your_server_ipwith the public IP address of your VPS or VDS.
For example:
ssh -i ~/.ssh/id_ed25519 [email protected]
Windows
You can use PowerShell or Windows Terminal to connect using OpenSSH.
- Open PowerShell or Windows Terminal.
- Run the following command:
Replace
your_server_ipwith your actual server IP address.ssh -i C:\path\to\private-key root@your_server_ip
For example:
ssh -i C:\Users\YourName\.ssh\id_ed25519 [email protected]
Specify an SSH Port
SSH uses port 22 by default. If your server uses a different SSH port, specify it with the -p option:
your_server_ip with your actual server IP address.ssh -i ~/.ssh/id_ed25519 -p 22 root@your_server_ip
Replace 22 with the SSH port configured on your server.
Complete the SSH Connection
When connecting to your server for the first time, SSH may display a message asking you to confirm the server's host key.
If you recognize the server and its IP address, enter yes.
SSH may also ask for the passphrase associated with your private key. Enter the passphrase you created when generating the SSH key.
Once authentication succeeds, you should see a command prompt similar to [root@server ~]#.
You are now connected to your self-managed VPS or VDS.
Troubleshoot SSH Connection Errors
If you cannot connect, check the following common issues.
Permission Denied (publickey)
If you receive a Permission denied (publickey) error, make sure that:
- You are using the correct private key.
- The corresponding public key was added to the server.
- The server IP address is correct.
- You are connecting with the correct username.
You can verify your SSH keys in the Bluehost Portal. For more information, see How to View Your SSH Key Content on a Self-Managed VPS and VDS.
Identity File Not Found
If SSH cannot find your private key, check the path specified with the -i option.
On Linux or macOS, you can view the SSH keys in your .ssh directory by running:
ls -l ~/.ssh/
Use the correct private key filename in your SSH command.
Bad Permissions on Private Key
On Linux or macOS, SSH may reject a private key if other users have access to the file.
To restrict access to your private key, run:
chmod 600 ~/.ssh/id_ed25519
Then try connecting again.
Connection Timed Out
If the connection times out, verify the following:
- Your VPS or VDS is running.
- You are using the correct public IP address.
- You are using the correct SSH port.
- Your server's firewall allows SSH connections.
Keep Your SSH Key Secure
Your private SSH key can provide access to your server, so keep it secure.
Follow these best practices:
- Never share your private key.
- Store your private key in a secure location.
- Use a passphrase to protect your private key.
- Never add your private key to the Bluehost Portal.
- Remove SSH keys you no longer need.
If you no longer need an SSH key, remove it from your server. For instructions, see How to Delete an SSH Key on a Self-Managed VPS and VDS.
Related Bluehost Articles
Summary
To connect to your VPS via SSH, use your private key with the command ssh -i /path/to/private-key root@your_server_ip, replacing the private key path and server IP address with your own information. If your private key is protected with a passphrase, enter it when prompted. Once authenticated, you can securely manage your self-managed VPS or VDS from the command line.
If you need further assistance, Bluehost Chat Support is available 24 hours a day, 7days a week while Bluehost Phone Support is available 7 days a week from 7 am-12 midnight EST.
- Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
- Phone Support -
- US: 888-401-4678
- International: +1 801-765-9400
You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.