I just configured Gitlab with a deploy key so that it doesn't ask for a username and password every time—but when pulling, it still fails with the following error:
[email protected]: Permission denied (publickey, keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What I did so far is this:
~/.ssh/id_rsa.pub in the Gitlab deploy keys sectionssh-add ~/.ssh/id_rsa~/.ssh with following contents:
Host gitlab.co
RSAAuthentication yes
IdentityFile ~/.ssh/id_rsa
git remote from the one using HTTPs to the one using SSH.I searched both Google and StackOverflow for a possible solution, but didn't find any similar discussion. Any ideas what I may be missing?
I was using sudo to do git pull, which resulted in the server trying to authenticate with the sudo user's SSH key.
I fixed it by changing the owner of the .git directory to be my logged-in user, meaning this command:
sudo chown -R ubuntu:ubuntu .git
After this, it all worked fine.
I believe this is a common scenario and I am now surprised I couldn't find more info about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With