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:
- Open your cPanel home page.
- Goto “SSH access” under the “Security” section.
- Click on “Manager SSH keys”.
- Click on “Generate a new key”.
- Enter the key name e.g. “my_test_key”.
- Set password and hit “Generate key”.
- Now, download the public and private keys into your system.
- Then click on the “Manage” button against your newly created public key.
- Click on the “Authorize” button.
- Now, open your Terminal in the folder where you downloaded the public and private keys.
- And run the command:
- ssh -i {your_key_name} {your_cpanel_username}@{your_shared_ip_address}
- and hit enter.
- 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.
- 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