4

I just created the git repo on bitbucket. Then I create the ssh key by follow:

   1. ssh-keygen -t rsa -C 'dien.vo@asnet.com.vn'
   2. ssh-keygen (press enter more)
   3. cat ~/.ssh/id_rsa.pub --> it return for me a SSH key
   4. Coppy that and added on bitbucket, then I save the new SSH key

After that I chose SSH link git like git@bitbucket.org:DienVo/abc.git, but In the terminal it show that

sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I don't know what is I wrong here, please help me to resolve it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

2 Answers2

10

Your ssh agent might not be working:

eval `ssh-agent -s` 
ssh-add

But you only need an agent if you generated an ssh key protected with a passphrase.
If not, your ssh key would work out of the box.

On Linux, check gnome-keyring which can interfere.

If the issue persists, debug with ssh -Tv git@bitbucket.org

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Alright @VonC , your suggestion partially fixed my issue, but when doing git pull I get prompted for the password anyway. Even though ssh -Tv git@bitbucket.org and ssh -T git@bitbucket.org tell me that "You can use git or hg to connect to Bitbucket. Shell access is disabled.". I don't really understand :S – xarlymg89 Apr 19 '18 at 09:31
  • @CarlosAlbertoMartínezGadea Does `ssh -T git@bitbucket.org ` display a "Welcome" message? What does git remote -v returns? Are you actually pulling from bitbucket? – VonC Apr 19 '18 at 09:33
  • yes, ```ssh -T git@bitbucket.org``` shows a welcome message saying that I'm logged in. And the same procedure of creating the SSH key worked on my Macbook Air. I'm pulling from Bitbucket. The same user that appears in the Welcome message with ```ssh -T git@bitbucket.org``` appears in the result of ```git remote -v``` poiting to my BitBucket repository. I'm a bit lost :S – xarlymg89 Apr 19 '18 at 09:38
  • @CarlosAlbertoMartínezGadea What git remote -v returns exactly? (just to make sure there is no https in it) Do you have an ~/.ssh/config file? What version of Git are you using? – VonC Apr 19 '18 at 11:15
  • I'm using Git 2.14.1. git remote -v does return https on the remote URLs. Why is that a problem? I don't have an ~/.ssh/config file. – xarlymg89 Apr 19 '18 at 11:48
  • 1
    @CarlosAlbertoMartínezGadea "git remote -v does return https on the remote URLs. Why is that a problem?" : it is a problem because https means all your SSH settings means nothing. It would still require your remote user account name/password, and that has nothing to do with SSH. You might consider using a credential helper like, on Linux, libsecret (https://stackoverflow.com/a/48237790/6309, and https://stackoverflow.com/a/42285250/6309 – VonC Apr 19 '18 at 12:21
  • 1
    I'll take a look to those links. Thanks for all the assistance – xarlymg89 Apr 20 '18 at 11:12
1

I faced the same issue in Ubuntu

Need to set the permission of your ssh folder, private and, public keys.

Run the below command in terminal

chmod 700 ~/.ssh
chmod 600 ~/.ssh/*

After restarting the terminal and try to connect the ssh connection.