Generating and Adding SSH Keys for cPanel Access Make it Rain Paper

  • SFTP, FTP/SFTP, FTP Accounts, SSH, SSH Login
  • 0

This guide is so that you can use to securely generate and add SSH keys to your cPanel account, enhancing your server security and enabling efficient file management.

Prerequisites

  • A terminal application (Terminal for macOS/Linux, PowerShell for Windows).
  • Access to your cPanel account.
  • Basic understanding of SSH and public key authentication.

Generating a New SSH Key

To establish secure access to your cPanel account, you need to generate a new SSH key pair. The simplest way is to use the ssh-keygen command.

For macOS

    1. Open Terminal.
    2. Run the following command:
ssh-keygen -t ed25519 -C "$comment/emailAddress"

Note: If your system does not support the Ed25519 algorithm, use:

ssh-keygen -t rsa -b 4096 -C "$comment/emailAddress"

For Linux

    1. Open Terminal.
    2. Run the same command as for macOS:
ssh-keygen -t ed25519 -C "$comment/emailAddress"

Note: Use the RSA command if necessary:

ssh-keygen -t rsa -b 4096 -C "$comment/emailAddress"

For Windows

    1. Open Windows Terminal.
    2. Run the command:
ssh-keygen -t ed25519 -C "$comment/emailAddress"

Note: Use the RSA command if necessary:

ssh-keygen -t rsa -b 4096 -C "$comment/emailAddress"

Adding Your SSH Key to the ssh-agent

Before adding your new SSH key to the ssh-agent, ensure you have checked for existing keys and generated a new one.

Starting the ssh-agent

  • macOS/Linux:
    eval "$(ssh-agent -s)"
  • Windows:
    Get-Service -Name ssh-agent | Set-Service -StartupType Manual
    Start-Service ssh-agent

Adding Your Private Key

In a terminal window (without elevated permissions for Windows), add your private key:

ssh-add ~/.ssh/id_ed25519

If you created your key with a different name, use that name instead of id_ed25519.

Adding Your SSH Key to cPanel

Once your SSH key is generated, you need to add the public key to your cPanel account:

  1. Log in to cPanel and navigate to Security » SSH Access.
  2. Click on Manage SSH Keys.
  3. To import an existing SSH key, click Import Key.
  4. Enter a custom key name if desired, or use the default (e.g., id_dsa).
  5. Paste your public and private keys into the appropriate text boxes and click Import.

Authorizing New Keys

After importing, you must authorize the new key:

  1. Go back to Manage your keys.
  2. Click to manage authorization for the key.
  3. Click Authorize to authorize the key, or Deauthorize to revoke it.

Copying the Public Key to Your cPanel Server

You can also copy the public key to your server using the ssh-copy-id tool:

ssh-copy-id -i ~/.ssh/id_ed25519.pub $user@host_or_IP

Once the public key is configured, users with the corresponding private key can log in without a password.

Important Notes

  • The SSH user's private key is encrypted, and you may be prompted for the key's password during SFTP connections.
  • cPanel users can also generate and download a private key via the SSH Access interface.
  • Root users can generate and download a private key via WHM's Manage root's SSH Keys interface.

See How to Connect to Your Server via SSH

Did something look off? Or maybe you've got a killer idea to make this article even better? Don't be shy—give us a shout! We're always up for improvement. Feeling creative? If you're itching to write something awesome, we're all ears! You can send your article ideas straight to our editorial team. We love fresh perspectives. Send us an email.


Did this answer help?

« Back