Git via SSH Asking For Your Password

The Issue

Few days ago, I was trying to git pull origin master from our master branch so I can get the latest version to develop on. Upon entering the command, this blankly (and blinkally) stared at me:

My-MacBook-Pro:branch_name loop$ git pull origin master
git@domain's password:

For the life of me, I have never seen this before. This particular branch worked fine just six days ago! 

I tried various things:

  1. Restarting com.openssh.sshd

  2. Restarting org.openbsd.ssh-agent

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

  4. Uncommented sshd_config's to PasswordAuthentication no

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

None of those fixes helped.

For some reason, Git stopped recognizing my public and private key (which was originally named github_rsa.pub and github_rsa respectively).

Eventually, I broke my silence, and my lovely French coworker Allan told me there's an easy fix - generate a new public/private key pair just for Gitlab.

The Fix

  1. In your favorite command line interface, generate a new SSH key:
    ssh-keygen -t rsa -C "name@domain.com"
    Note: For this scenario, when it prompted me to enter a password, I left it blank, since this key is simply for internal use.
  2. Dump the contents:
    cat ~/.ssh/id_rsa.pub
    
  3. Finally, copy the contents and add to Gitlab.

Pretty simple stuff. Let me know if this helped you in anyway - it seems this issue is quite common with Gitlab.