How to generate SSH keys from cPanel and use it in Terminal

Following are the steps to generate SSH keys from cPanel and use them in your Command Prompt or Terminal:

  1. Open your cPanel home page.
  2. Goto “SSH access” under the “Security” section.
  3. Click on “Manager SSH keys”.
  4. Click on “Generate a new key”.
  5. Enter the key name e.g. “my_test_key”.
  6. Set password and hit “Generate key”.
  7. Now, download the public and private keys into your system.
  8. Then click on the “Manage” button against your newly created public key.
  9. Click on the “Authorize” button.
  10. Now, open your Terminal in the folder where you downloaded the public and private keys.
  11. And run the command:
    • ssh -i {your_key_name} {your_cpanel_username}@{your_shared_ip_address}
    • and hit enter.
  12. If you get an error: Permission for keys are too open then run the command:
    • chmod -R 600 {your_key_name}
    • where my_test_key is the name of your key you set during creation.
  13. If you did not get that error, then you will be asked to enter a password. Simply enter the password you set during the creation of the key and it will enter you in the SSH in your Terminal.

SSH is mostly required when you are deploying your project from localhost to the server. Frameworks like Laravel require most of the command-line work. In situations like these, you can generate SSH keys and easily connect with your live server using your command prompt (CMD) or terminal.

Sometimes you were unable to delete a file or folder from the cPanel file manager, so you can delete it from SSH by running the following command:

rm -rf name_of_file_or_folder