DEV Community

Ibrahim Adedeji
Ibrahim Adedeji

Posted on

How to Connect to Github Repository from Cpanel Terminal (without password authentication)

Normally, you could simply log on to your website’s cpanel, open the terminal, cd to your project folder, type git pull, enter your github username and password on prompt and have the latest changes to your project pulled. Similar process if you’re cloning a repository to your hosting account for the first time. However, since 13th August 2021, github has stopped allowing username/password authentication via ssh. You’re likely to see a message similar to the one below:

a1

Well, this article intends to simply show how to do that.

  • On your cpanel dashboard, find “SSH Access” on the “Security Pane”, click on it
  • Click on the “Manage SSH Keys” Button

a2

  • Next, it should take you to a page where you’d see a list of ssh keys for your hosting account. One table lists the public key(s) and the second one lists the “Private Keys”.

a3

If there are existing keys on your account, you should see them listed as above. If not, click on the “Generate a new key” button at the top of the page. The id_rsa named key is one you’d probably find existing already.

  • On the Public Keys Table, click “Manage” for any of the listed public keys, the “id_rsa” for example

a4

If the next page is similar to the one above, there’s nothing else to do here, simply click on “Go back”. If the page however shows that the key is not authorized, click on “Authorize” to authorize the public key.

Next, you have to add this key to your github account. The steps are highlighted below:

  • On the SSH Keys page, click “View/Download” for the desired and authorised public key

image

image

Copy the content of the box

  • Go to github
  • Click on your profile picture at the top right corner of the page, on the nave bar and click on “Settings”

image

  • Go to “SSH and GPG Keys” on the left pane
  • Click on “New ssh key”
  • Enter a descriptive title in the “Title” field
  • Paste content of the public key you copied earlier in to the “Key” text box
  • Click on “Add SSH Keys”
  • Next, open your cpanel terminal

To test it worked, type ssh -T git@github.com
If you got a message similar to Hi <github username>! You’ve successfully authenticated.., congratulations
Now, you can cd into the desired folder, type git pull git@github.com:your_username/your_repo.git

This summarises the steps needed. I do hope it helps

Top comments (0)