Secure Shell (SSH) allows you to access your cPanel account via the command line, offering a secure and efficient way to manage files, run commands, and configure your server. SSH is especially useful for advanced users who want more control over their server without relying on the graphical interface.

In this guide, you will learn how to:

  1. Enable SSH access in cPanel (if needed).
  2. Generate an SSH key pair in cPanel.
  3. Connect to your cPanel account via SSH using a terminal (Mac/Linux) or an SSH client (Windows).

1. Enable SSH Access in cPanel

SSH access is typically enabled by default in most hosting plans, but if it's not available or you’re unsure, you may need to enable it or contact your hosting provider for assistance.

To check or enable SSH in cPanel:

  1. Log in to your cPanel account.
  2. In the Security section, look for the SSH Access or Manage SSH Keys option.

If SSH is disabled, contact your hosting provider to enable it for your account.

2. Generate an SSH Key Pair in cPanel

Before connecting via SSH, you’ll need an SSH key pair (public and private keys). You can generate these directly in cPanel.

  1. Log in to your cPanel account.
  2. In the Security section, click on SSH Access.
  3. On the SSH Access page, click Manage SSH Keys.
  4. Click Generate a New Key.
  5. Fill out the form:
    • Key Name: You can leave this blank for the default name (id_rsa), or enter a custom name.
    • Key Password: Choose a strong password to protect your private key.
    • Key Type: Select RSA (recommended).
    • Key Size: Set this to 2048 or 4096 bits (4096 is more secure).
  6. Click Generate Key.

Once the key is generated, you will have both a public and private key. The public key will be automatically installed on the server.

3. Authorize the SSH Key

After generating the key, you need to authorize it for SSH access:

  1. Go back to the Manage SSH Keys page.
  2. Under Public Keys, find the key you just generated and click Manage.
  3. Click Authorize to allow SSH access with this key.

4. Download the Private Key

To connect via SSH, you will need the private key stored locally on your computer.

  1. In the Manage SSH Keys section, scroll to the Private Keys section.
  2. Click View/Download next to the private key you generated.
  3. Click Download Key, and save the file to a secure location on your computer.

If the key is in OpenSSH format, it may need to be converted to PPK format for some clients (like PuTTY on Windows), which we’ll cover below.

5. Connecting to Your cPanel Account via SSH

A. On Mac or Linux (Using Terminal)

  1. Open the Terminal application.

Use the following command to change permissions for the private key (replace /path/to/your/private_key with the actual path where you saved the key):
bash
Copy code
chmod 600 /path/to/your/private_key

Connect to the server using this command (replace username, server_ip, and /path/to/your/private_key accordingly):
css
Copy code
ssh -i /path/to/your/private_key username@server_ip

  • username: Your cPanel username.
  • server_ip: The IP address or domain of your server (you can find this in cPanel under General Information or by contacting your hosting provider).
  1. If this is your first time connecting to the server, you'll be prompted to confirm the server's authenticity by typing yes.
  2. Enter the passphrase you used when generating the key (if applicable), and you should be connected to your cPanel account via SSH.

B. On Windows (Using PuTTY)

  1. Convert Your Private Key to PPK Format (if necessary):
    • Open PuTTYgen (download from PuTTY's website).
    • Click Load and select your private key file.
    • Click Save Private Key to convert the key to .ppk format.
  2. Open PuTTY:
    • Enter your server’s IP address or hostname in the Host Name field (e.g., server_ip or yourdomain.com).
    • In the left-side menu, go to Connection > SSH > Auth.
    • Under Private key file for authentication, click Browse and select the private key (.ppk) file you saved.
  3. Go back to the Session page, and click Open to start the SSH session.
  4. When prompted, enter your cPanel username. PuTTY will use your private key to authenticate.

You’re now connected to your cPanel account via SSH on Windows!

6. Troubleshooting SSH Connection Issues

  • Permission Denied (Public Key): Ensure the public key is authorized on the server, and the private key file has the correct permissions (chmod 600).
  • Connection Timed Out: Check that SSH access is enabled by your hosting provider and the correct port (usually port 22) is open.
  • Host Key Verification Failed: This happens when the server's fingerprint has changed. You can delete the old entry from your known_hosts file (on Mac/Linux) or reset it in PuTTY.

Conclusion

Connecting to your cPanel account via SSH allows you to securely access and manage your server using command-line tools. By generating and authorizing an SSH key, and using an SSH client or terminal, you can streamline server management tasks such as file editing, backups, and running scripts. Follow the steps above for your platform, and you’ll have SSH access to your cPanel account in no time!

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)