The customer portal my.neoserv.com has been redesigned. If you notice any issues, please let us know.

Cart (0)
  • Your cart is currently empty.

NEOSERV BLOG

Tips, guides and useful information about domains, hosting, SSL certificates, email, web optimization and online security.

cPanel in SSH ključi
Category: Web Hosting
Published:

SSH keys are strings of encrypted symbols used to authenticate accounts on a server. Because they are not susceptible to brute force attacks and at the same time are not human-friendly, they are often used by advanced users to securely access a server environment.

In today’s post, we’ll show you how to create an SSH key in the cPanel control panel to access a hosting package, and then how to automate the login via the PuTTY client.

To manage SSH keys, follow this procedure:

  1. Find the settings for SSH key management
  2. Create an SSH key and authorise it
  3. Use the SSH key
  4. Automate the use of the SSH key

1. Find the SSH key management settings

Log in to the cPanel control panel(login instructions) and navigate to the SECURITY section. Find the SSH Access icon and click on it.

cPanel - SSH Access

On this page you can read more about what SSH or an SSH key is. Under the description you will also find the Manage SSH Keys button.

Manage SSH Keys

Click on the Manage SSH Keys button to complete step 1. Now it’s time to create a new SSH key.

2. Create an SSH key and authorise it

By clicking on the Generate a New Key button you will create a new SSH key. If you want to use an existing one, import it by clicking Import Key.

Creating a New SSH Key

After clicking on the button to create a new key, you will see the fields you need to fill in:

  • Key Name: specify the name of the key.
  • Key Password: set a strong password to protect the key (we recommend using a password generator).
  • Reenter Password: re-enter the password you entered in the field above.
  • Key Type: select the type of key – DSA or RSA, depending on your preference (we recommend RSA).
  • Key Size: specify the size of the key – choose between 1024-, 2048- or 4096-bit length.

Generating a Public Key

Once you have specified a strong password and filled in the remaining fields, click on the Generate Key button. You will see a notification, similar to the one shown below, that the key generation has been successfully completed.

Notification of Completed SSH Key Creation

At the same time as you create the public key, the private key is automatically created as SSH keys must work in pairs. However, before you can use the public key, you must authorise it. Note that you only authorise the public key, as it will be located on the server. You will store the private key yourself, using the PuTTY client for configuration.

To continue the process, click Go Back and then select Manage from the list of SSH keys.

Managing the Public Key

Click Authorize to authorise the SSH key to access the account. Then click Go Back.

SSH Access Authorization

Now convert the private key to the .ppk format (PuTTY private key) and download it to your computer in the next step. Click on View/Download in the list next to the private key.

Downloading the Private Key to Your Computer

At the very bottom you will find a box where you can enter the password you set in one of the previous steps and click on the Convert button.

Converting an SSH Key to PPK Format

Then click on the Download Key button to download the private key to your computer (e.g. your desktop).

3. Use the SSH key

To use the SSH key, you will need a PuTTY client to establish an SSH connection to the server.

After installing the program, open the Session section and use the following settings:

  • Host Name (IP Address) – Enter the host name or IP address of the server on which you have a leased hosting package. You will find this information in the My NEOSERV Subscription Centre or in the cPanel Control Panel, in the column on the right. By clicking on Server Information you will also find the name of the server. If the Server Name is sh4, the name of your host is: sh4.neoserv.si
  • Port – Set the port for SSH access: 5050
  • Connection type – Use the connection type: SSH
  • Saved Session – Specify the name of the session you want to save or upload.

PuTTY - Session

You can now add the username of your cPanel account that will be used to establish the SSH connection. To do this, navigate to the Connection / Data section and enter your username in the box above.

PuTTY - Connection / Data

Once again, navigate to the Session section and save the session again so that the username you added will be used for this session.

Then upload the SSH private key you downloaded to your computer earlier. To do this, navigate to the SSH/Auth section and click Browse… selecting the .ppk file.

PuTTY - Connection / SSH / Auth

Navigate to the Session section again and save the session again.

4. Automate the use of the SSH key

If you connect to a server via SSH frequently or manage multiple accounts or hosting packages, it can be time-consuming to constantly enter your password. Fortunately, there are solutions that can automate this process.

Pageant

PuTTY comes with a few additional executables, including pageant.exe (the SSH authentication agent for PuTTY, PSCP, PSFTP and Plink). If for some reason you don’t have this file installed, you can download it separately.

Pageant can remember your password and then use it every time you log in to the server via an SSH connection. However, Pageant usually forgets all your keys when you close it as a security measure, so you will need to add them again the next time you restart it. Below we’ll look at how you can avoid this.

After starting Pageant, it will minimise the Pageant in the system tray. Right-click its icon and select Add Key or View Keys. Both options allow you to add a new key.

Pageant

Find the .ppk file you recently downloaded to your computer and enter the password for your key. As shown in the screenshot below, you will then see your SSH key in the Pageant key list.

Pageant - Key List

To avoid having to re-enter your password, go to the directory where you installed PuTTY. Right-click the pageant.exe file on your desktop and create a shortcut. Then right-click on it and select the Properties option below. Navigate to the Shortcut tab.

Pageant - Shortcut Properties

You will now need to edit the Target field and enter the location of the key. If you have the key stored on your desktop, you should fill in the field as follows:

"C:\Program Files\PuTTY\pageant.exe" C:\Users\Admin\Desktop\id_rsa.ppk

Adjust the above path accordingly! In particular, pay attention to the Admin record, as you are most likely using a different username in your operating system. When you are sure that the path is correct, click Apply and OK. You can now run PuTTY.

PuTTY - authentication with Pageant

If you want to automate the process further, you can eliminate the initial PuTTY startup. You can also leave this to Pageant by adding the -c command and the system path to PuTTY to the end of the Target field mentioned earlier.

"C:\Program Files\PuTTY\pageant.exe" C:\Users\Admin\Desktop\id_rsa.ppk -c "C:\Program Files\PuTTY\putty.exe"

Re-confirm the new settings to complete the whole process. You can now access your hosting package, or even multiple packages on different servers, via an SSH connection – securely and with just a few clicks.

Linux OS

On Linux, you can set up login automation with a simple command in the terminal:

ssh-add ~/.ssh/id_rsa

This command loads a private key into the SSH agent, thus keeping the key in memory as long as the agent is active (e.g. until a reboot). If your key has a password, you will have to enter it once, after which each subsequent SSH connection will be established without prompting for the password again.

Windows OS

On Windows, you can achieve login automation from the PowerShell command line using OpenSSH, which is included with modern versions of Windows 10/11:

ssh-add $env:USERPROFILE\.ssh\id_rsa

Again, a password prompt will appear when the command is run, and after successful authorisation, the connection to the server will be made without entering the password again.

Note that the SSH agent must be active. This is usually started by default in a Linux environment, while in Windows OS it is started with the Start-Service ssh-agent command (in PowerShell). If you want the agent to start automatically at each system boot, add the Set-Service -Name ssh-agent -StartupType Automatic command. Otherwise, the ssh-add command will return an error or the key will remain inactive.

Using an SSH connection with key authentication increases security and speed when managing web hosting or servers. Although the initial setup is slightly more complex than using a password, it will save you time in the long run and reduce the risk of unauthorised access. And with Pageant or the built-in SSH agent in Linux or Windows OS, you can further automate login and simplify your work.

COMMENTS

COMMENT THE POST

(mandatory)
(mandatory, email address will be hidden)
(optional)
Security question that confirms you are a real person.