Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?

Quick way to solve Git problem: Permission denied

This was examined with non-root person and works for GitHub & GitLab (for 2FA enabled as nicely).

You might encounter the next drawback whereas your improvement:

git@gitlab.com: Permission denied (publickey,keyboard-interactive).
Enter fullscreen mode

Exit fullscreen mode

On this article I’ll present a option to resolve this, and never solely.

If you have already got setup SSH key in your distant platform (equivalent to GitHub), simply skip this half.

Including SSH to your Git account.

Run this command to generate public & non-public key information:

# throughout creation of SSH information you'll be able to go away passphrase empty
# right here you'll be able to set the private-key & public-key file names/paths
ssh-keygen -t ed25519 -C "<GIT_ACCOUNT_EMAIL>"
Enter fullscreen mode

Exit fullscreen mode

Print the output of public SSH file and duplicate the output content material.

# let's assume we've got setup default "id_ed25519.pub"
cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode

Exit fullscreen mode

We are going to do that for GitHub as an example. However virtually you are able to do the identical for the opposite Git platforms as nicely.

Login to your account and go to the “Add SSH key” part. Use the copied public-key content material for including as a brand new SSH key into your account.

Check the SSH authentication for GitHub:

# for GitHub
ssh -T git@github.com

# for GitLab
ssh -T git@gitlab.com
Enter fullscreen mode

Exit fullscreen mode

Fixing the problem:

Typically SSH authentication check fails, and also you may get one thing like this:

git@gitlab.com: Permission denied (publickey,keyboard-interactive).
Enter fullscreen mode

Exit fullscreen mode

For avoiding this, you’ll be able to observe to those steps:

# cd into ".ssh" listing
cd ~/.ssh

# be sure to have private-key file octal permission as 600
stat -c "%a %n" *

# if not, then you'll be able to change the permission like this
# in our case we would have this file: "id_ed25519-gitlab"
sudo chmod 600 id_ed25519-gitlab

# [FREQUENTLY USED] if the permissions are right, begin your SSH agent
eval `ssh-agent -s`
# it will output one thing like this:
"Agent pid 21590"

# [FREQUENTLY USED] now add your SSH private-key because the licensed person
ssh-add ~/.ssh/id_ed25519-gitlab
# you need to get one thing like this
"Identification added: /residence/<LOCAL_USER>/.ssh/id_ed25519-gitlab (<ACCOUNT_EMAIL>)"

# now check the SSH authentication once more
# you need to get some success message, one thing like this:
"Welcome to GitLab, @<USERNAME>!"
Enter fullscreen mode

Exit fullscreen mode

Typically connection will not be working between your machine and the Git server, however it’s possible you’ll need to push your code someplace remotely.
In this sort of circumstances you’ll be able to add the choice/one other distant and push the venture there:

git distant rename origin upstream
git distant add origin git@gitlab.com:<USERNAME>/<REPO_NAME>.git
git push origin <BRANCH>
Enter fullscreen mode

Exit fullscreen mode

For current repos (with HTTPS utilization) change distant origin as SSH if wanted:

git distant set-url origin git@github.com:<USERNAME>/<REPO_NAME>.git
Enter fullscreen mode

Exit fullscreen mode

That’s it.

In the long run, simply in case right here’s some helpful sources which you’ll use:


For those who appreciated this text, be happy to observe me right here. 😇

To discover initiatives working with numerous fashionable applied sciences, you’ll be able to observe me on GitHub, the place I actively publicize a lot of my work.

For more information you’ll be able to go to my web site boolfalse.com

Thanks !!!

Add a Comment

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?