Cpanel 0

How to connect via SSH to a cPanel web hosting account


How to Set Up SSH on a cPanel Account

Introduction

SSH (Secure Shell) is a cryptographic network protocol for operating network services securely over an unsecured network. It provides a secure channel over an insecure network in a client-server architecture, connecting an SSH client application with an SSH server. This article will guide you through setting up SSH on your cPanel account.  

Generating an SSH Key Pair via cPanel

Before you can connect to your server using SSH, you need to generate an SSH key pair. This pair consists of a public key and a private key.

  1. Log in to your cPanel account.
  2. Navigate to the Security section and click on SSH Access.
  3. Under Manage SSH Keys, click Generate a New Key.
  4. Choose a Key Name (e.g., id_rsa).
  5. Set a Key Password (This will need to be entered each time you connect)
  6. Click Generate Key.

Understanding the Keys

  • Public Key: This key is shared with the server and authorizes your access. This file will be called the name you entered above with the suffix .pub
  • Private Key: This key remains on your local machine and is used to prove your identity to the server.

Authorizing the Public Key on your Server

  1. In your cPanel SSH Access interface, click Manage SSH Keys.
  2. Under Manage SSH Keys, check the Authorization Status of your keys.
  3. If Unauthorized, click Manage
  4. Click Authorize.

Generating an SSH Key Pair via desktop

  1. If using either macOS or Linux, you can generate the keys yourself.
  2. In your terminal, type the following command:
    ssh-keygen
  3. You'll be prompted for:
    • File location: Press Enter to accept the default location (~/.ssh/id_rsa).
    • Passphrase: You can leave this blank for easier access, but for enhanced security, create a strong passphrase.
    • Confirm passphrase: Re-enter the same passphrase.
  4. Lastly, you will need to copy your public key to your cPanel account as above, and ensure that it is authorised

Connecting to Your Server via SSH

To connect to your server using SSH, you'll need an SSH client. Popular options include:

  • PuTTY (Windows)
  • OpenSSH (macOS and Linux)
  1. Open your terminal.
  2. Enter the following command:
    ssh -p 22 UserName@DomainName​
    • You will be prompted for your password or SSH key passphrase.
    • The port number will need to be supplied by your web hosting provider
    • The UserName can be found in the side panel of your hosting account
    • The DomainName will need to be amended to your needs

Additional Tips

  • Key Security: Keep your private key secure. It's crucial for accessing your server.
  • Passwordless Login: Using SSH keys often allows for passwordless login, enhancing security.
  • SSH Agent: Consider using an SSH agent to manage your SSH keys efficiently.
  • Authorized Keys File: You can manually manage SSH keys by editing the authorized_keys file in your home directory.

Troubleshooting

If you encounter issues, consider the following:

  • Firewall: Ensure your firewall allows SSH connections (port 22).
  • Key Permissions: Verify that your private key has the correct permissions (e.g., chmod 600 ~/.ssh/id_rsa).
  • SSH Configuration: Check your SSH client configuration for any errors.
  • Network Connectivity: Verify network connectivity to your server.

By following these steps, you should be able to successfully set up SSH on your cPanel account and securely connect to your server.

If you are having trouble connecting to your account with Encode, please log in and raise a support ticket for our team to help.


Was this answer helpful?

One email a month. Endless business benefits.

Don't miss out on WMTWWFY — the newsletter that keeps your website fast, safe, and visible.

« Back
Spinner
aluminium-anthropoid Security Check