I’m stuck using https for git pulls… I have tried to switch to ssh but every time I try to add my identity, I get a “Could not open a connection to your authentication agent”.
I tried creating many keys and adding them to git but to no avail. I’m turning to the forums to get some guidance
sudo git pull
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I’m on ubuntu 16.04
These are the contents of my ~/.ssh/
-rw------- 1 macrandle macrandle 744 Nov 8 07:40 authorized_keys
-rw-rw-r-- 1 macrandle macrandle 120 Mar 23 06:18 config
-rw------- 1 macrandle macrandle 3326 Nov 8 08:02 id_rsa
-rw-r--r-- 1 macrandle macrandle 743 Jan 13 22:19 id_rsa.pub
-rw------- 1 root root 3326 Mar 23 00:17 id_rsa_work
-rw-r--r-- 1 root root 743 Mar 23 00:17 id_rsa_work.pub
-rw-r--r-- 1 macrandle macrandle 2652 Jan 13 22:29 known_hosts
I’m trying to add id_rsa_work and my keys are added to my github account
I have tried
eval $(ssh-agent)
and then
sudo ssh-add ~/.ssh/id_rsa_work
this leads to “Could not open a connection to your authentication agent”
Any help would be great.
Cheers
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.
@acspock
Do not use
sudo
.Make sure your
id_rsa.pub
is added to your github account.I saw some possible solutions in a forum at Github, so I credit this thread. but since it directly pertains to Digital Ocean customers, I thought it’d be useful to have the content here.
This error happens more. It is most likely caused by errors in your gitlab-shell database (specificly the ssh database) and actualy happens on most preïnstalled digitalocean packages. Fixing this issue is very easy in most cases. Just follow the steps bellow (all commands are performed server-side):
Step 1 - Clean your SSH configuration
The shell command below will reset all gitLab-keys that could still be hanging around in the basic Linux Environment (if you are not on root add sudo to the second command bellow)
•
cd /bin
•./bin/gitlab-keys clear
Step 2 - Clean your gitlab-shell database
Then if your problem is not fixed, the command below will drop the gitlab-shell database, create it again and populate it with the right migrations (don’t forget the sudo command here even if you are on root since we’re going to give it parameters). please note after these commands all website users will need to re-add their ssh keys to their accounts…
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production Now restart the server to reload all scripts, environments and stuff. You could just restart the gitlab application, but In my experience a full server restart triggers more environment details (like the ssh configuration and stuff) again if you are not on root use sudo to shutdown… restarting servers is a sudo thingy…
shutdown -r 0 Broadcast a message on your website (see admin area -> messages or /admin/broadcast_messages) explaining that you removed all public keys from all users on your gitlab server. Users will freak out and think that their accounts/keys are stolen/hacked/whatever… It will save you the trouble of having people spamming you.
Problem not fixed?
You could experience other issues. try installing htop, a monitor application for system usage to review your computer’s presentation-status.
•
sudo apt-get install htop
•htop
Used memory and swap ridiculously high? Try expanding them ;)