Question

login to Ginhub

Posted September 22, 2021 113 views
GitDjangoDeployment

Trying to deploy a django I constantly failed to authenticate my Github account.

I face two different issues:

  1. How to automate the Github authentication?

  2. Which password should I use?

I run:

ssh keygen
add key.pub
add agent and authenticate

In Github I:

  • added new ssh
  • generated personal token
  • switched https to ssl

On my DO server I note the file /etc/ssh/sshd_config has:

PasswordAuthentication no

#Port 22
##HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed----_key

Should I uncomment any of these?

After adding the clone git command I request to add my GitHub username and password… then it fails.

I tried with:

  • Git personal token
  • id_rsa.pub
  • pasting the actual string of the key
  • clone into Https or ssh
  • ssh -T git@github.com

I constantly fail.

I run the command to a user (not root) that was granted rights.

Any tip, advice on how to overcome this hurdle would be highly appreciated

edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello,

In order to use SSH as your GitHub authentication method you need to do the following:

  • Check if you have an SSH key pair already, by running the following command on your server:
cat ~/.ssh/id_rsa.pub

If you do not have an SSH key pair already on your server, generate a new one with the following command: ssh-keygen.

  • Once you have your public key, copy it and then go to GitHub -> Settings -> SSH keys -> and add the public key there.

Make sure that the key is added correctly without any new lines.

Once you’ve added your SSH key there, make sure that you clone your repository with SSH and not HTTP. Your repository URL should look like this:

git@github.com:YOUR_USER/YOUR_REPO_NAME.git

You should not make any changes to the sshd_config file as this file is your SSH server configuration file for your Droplet itself and should not affect your GitHub SSH connection.

For more information on how to get started with Git I would recommend this free eBook here:

Introduction to Git and GitHub

Let me know how it goes.
Best,
Bobby

  • Hi Bobby,

    Thanks for your reply.

    I already followed these steps, I tried them now again… am still at square one.

    My problem is that after I enter my git password, the authentication fails.

    I thought the SSH would authenticate the user, but I was wrong.

    How exactly should I enter my SSH key on the server so git authenticate me?
    Should I copy the full SSA public key? The variable (id_rsa.pub)? git access token? else?

    Cheers,

    Yariv

    • Hi Yariv,

      If you’ve cloned your repository with SSH it should not ask you for a password.

      To verify if this is the case, you could check your Git config file by first going to your repository directory and then run the following command: cat .git/config.

      In there you should look for the following part:

      [remote "origin"]
              url = git@github.YOUR_USER/YOUR_REPO.git
      

      Feel free to share the content of your config file here if you wish, just make sure to remove any sensitive information from there first.

      Best,
      Bobby