Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH Key Keeps Asking for Password on Gitlab

Tags:

git

macos

ssh

I have been debugging the issue for an hour or two now.

I am currently using Gitlab and Mac OS X 10.9.2.

Today, I was trying to git pull origin master from our master branch so I can get the latest version to develop on. I have always used these configurations, and don't recall changing anything. This configuration has always worked, and never prompted me for a password. Today, I got this error:

My-MacBook-Pro:branch_name loop$ git pull origin master

git@domain's password:

Here are my ~/.ssh/permissions:

My-MacBook-Pro:.ssh loop$ ls -l

total 24

-rw-------  1 loop  staff  1766 Oct 31  2013 github_rsa

-rw-r--r--  1 loop  staff   403 Oct 31  2013 github_rsa.pub

-rw-r--r--  1 loop  staff  2408 Sep 15 15:08 known_hosts

I have tried various things:

  1. restarting com.openssh.sshd

  2. restarting org.openbsd.ssh-agent

  3. I made sure that my public key on Gitlab is the same as my github_rsa.pub, and it indeed was the same.

  4. I have uncommented sshd_config's to PasswordAuthentication no

  5. Checked /var/log/authd.log for errors relating to SSH, but nothing relevant.

What could be the issue?

like image 496
theGreenCabbage Avatar asked Sep 25 '14 11:09

theGreenCabbage


People also ask

How do I fix Git always asking for credentials?

You can avoid being prompted for your password by configuring Git to cache your credentials for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.

Why does SSH keep asking for passphrase?

SSH passphrases protect your private key from being used by someone who doesn't know the passphrase. Without a passphrase, anyone who gains access to your computer has the potential to copy your private key.

Why does Git ask for password every time?

Why Git Keeps Prompting you for Username and Password. Using HTTPS remote URL is useful if you need to work through strict firewalls and proxies but this also means that you'll get prompted for your GitHub username and password each time you pull or push your code to your repository.


2 Answers

Rename the file github_rsa to id_rsa.

SSH looks for the private key by "name" id_rsa in .ssh folder of your home.

Its not able to find it now because you have renamed it.

PS: Whenever you encounter a problem in SSH try running it with option -vvv so that you get a verbose output!

Hope this solves the problem!

Happy Gitting!

like image 87
Mudassir Razvi Avatar answered Sep 30 '22 10:09

Mudassir Razvi


Fixed this by generating a new public/private key just for Gitlab with no password.

Create a new SSH key:

ssh-keygen -t rsa -C "[email protected]"

Note: For this scenario, when it prompted me to enter a password, I left it blank, since this key is simply for internal use.

Dump the contents:

cat ~/.ssh/id_rsa.pub

Finally, copy the contents to add to Gitlab.

like image 36
theGreenCabbage Avatar answered Sep 30 '22 08:09

theGreenCabbage