1. Home
  2. cPanel/WHM
  3. How do I connect to my web hosting account using SSH?

How do I connect to my web hosting account using SSH?

Only the main user of a cPanel account can connect via SSH to the service. Thus, users created via the Manage Team feature cannot manage a web hosting account via SSH.

Via cPanel

You can always access a terminal through cPanel. Please follow these instructions to do this:

  1. Login to cPanel.
  2. Click on the icon called Terminal under the Advanced section.
  3. A warning will appear on the next page if you have not used the terminal before. If you are comfortable using a terminal and want to go ahead, click the blue button.
    cPanel Terminal Warning
  4. You now have complete access to your account through the terminal.

Via SSH client

Keep in mind that you always must use your cPanel username when logging on via SSH.

To connect with SSH to our servers you are required to use keys. This guide will walk you through how to create a public key which is stored on the server along with a private key that is stored on your computer.

Create a key pair

  1. Login to cPanel.
  2. Click the SSH Access icon in the Security section.
  3. Click on Manage SSH Keys.
    Manage SSH Keys
  4. Click on Generate a New Key.
    Generate a New Key
  5. You now need to fill out the following information:
    • Key Name: You can choose any name you wish, for example “id_rsa” which is the default name.
    • Key Password: A password for your private key. The strength has to be over 50 for the password to be accepted.
    • Reenter Password: Enter the same password again.
    • Key Type: RSA.
    • Key Size: We recommend using 4096 bit.
      Generating a Piublic Key
  6. You can now generate the key by clicking Generate Key.

If you click on Go Back you will return to the page with your SSH keys. There should now be two keys there, one public and one private.

Activating the Key

  1. On the Manage SSH keys page you need to click on Manage to the right of your public key.
    Public Key - Manage
  2. Then click on Authorize.
    Authorize
  3. The SSH key is now authorized to access your account, you can click Go Back to get back to the Manage SSH keys page.

Download the private key

  1. On the Manage SSH Keys page click on View/Download to the right of the private key.
    View/Download
  2. If you are going to use PuTTY you will have to convert your key into PuTTY-format. If you are not going to use Putty you can skip to step 4.
  3. For Putty users. In the field Enter the passphrase to unlock the "key name" key for conversion you need to enter the password for your private key which you set when you created it. Then click Convert.
    Enter The passphrase
  4. Click on Download Key to save the key some where on your computer.

When the private key has been saved to your computer it is important that you click Delete to remove the private key from the server.

Set up PuTTY (Windows)

If you are running Windows 8.1 or earlier you can use a program called PuTTY to connect with SSH to the server. If you don’t have PuTTY you can download it here. To set up PuTTY to use your private key you need to follow these steps:

  1. Open up PuTTY and load the session you want to edit the settings for. If you do not have any session saved since earlier you can go to next step.
  2. Click on Connection -> SSH -> Auth.
  3. Click on Browse and find the private key file you downloaded and saved from the server earlier.
  4. Go back to Session and click Save. If you do not already have a session you need to enter a name before you click Save.
  5. In the field Host Name you need to enter the name of the server you are going to connect to. You can find the host name you need to use by following this guide.
  6. Click Open to start the SSH session.
  7. If you configured everything correctly PuTTY will now ask you if you trust the server, enter yes.
  8. PuTTY should now ask for your username, you will need to type in your cPanel username. If you do not know which cPanel username you have you can follow this guide all the way to step four to find out.
  9. At last PuTTY will ask you for the password for your private key. It is the same password as you entered when you created the key pair in cPanel (as described above).
  10. You should now be logged in to your account over SSH.

Connecting with PageAnt (Windows)

PageAnt requires that you already have PuTTY installed.

PageAnt is a program that keeps track of your keys. Every time PageAnt starts you can add your key (you will have to enter the password for the key). With PageAnt running you can make connections with PuTTY without having to enter your password every time you connect to a server.

Download PageAnt from Puttys website.

When PageAnt has been installed you should get an icon (looking like a computer with a hat on) in Windows Task Bar. Right click on the icon and then click Add Key, choose the private key file which you downloaded earlier.


You also have to enter the password for your private key.

Now you should be able to connect to the server with PuTTY without having to enter your password.

Connecting with SSH in Terminal (Unix/Linux/Mac/Windows 10)

For Mac users you can find the Terminal through Finder by searching for the word “terminal”.

If you are using Windows 10 you can use Bash on Windows 10 (WSL) to get access to the SSH client.

To use the private key you downloaded earlier you can add the -i flag to the ssh command:

ssh -v -i /path/to/private_key cpanelusername@servername

If you don’t know which cPanel username you have you can follow this guide all the way to step four to find out.

If you don’t know which server name to use you can follow this guide to find out.

The private key on your computer should only be readable by your user. You can run chmod 600 /path/to/key to achieve this (replacing /path/to/key with the path and name of the file containing the private key).

If you get disconnected too often

Sometimes when you connect via SSH and leave the connection idle for a while, the server may disconnect automatically. This is normal, but if you think that the server is a bit to aggressive when it comes to automatic disconnects, you may need to adjust your connection settings.

Using Putty (Windows)

  1. To adjust the setting regarding connection timeout in Putty, you need to edit the session you created above.
  2. In the pane Category, go to Connection. Under Sending of null packets to keep session active, enter 240 for Seconds between keepalives.

  3. Now, click Session under Category and then on Save.
  4. Test your connection and leave it connected for a while to test the timeout. If the server still disconnects too often for your taste, edit Seconds between keepalives to a lower number in steps to find the value that suits your needs.

Using Unix/Linux/Mac/Windows 10 with bash

Edit the file ~/.ssh/config (or create it if it doesn’t exist yet) on the device you’re connecting from:

Host servername.oderland.com
    Hostname servername.oderland.com
    ServerAliveInterval 240
    ServerAliveCountMax 2

If you do not wish to edit the config file, you can use the same settings directly in your command when you connect:

ssh -i /path/to/private_key -o ServerAliveInterval=240 -o ServerAliveCountMax=2 cpanelusername@servername.oderland.com

Regardless if you’re using the config file or the connection command above, swap out servername.oderland.com with the correct server name for the account.

Test your connection and leave it connected for a while to test the timeout. If the server still disconnects too often for your taste, edit ServerAliveInterval to a lower number in steps to find the value that suits your needs.

Was this article helpful?

Related Articles