5

The Problem

I recently installed Kubuntu 16.04.2 on my computer. Since then, I can no longer use my ssh keys to access bitbucket and github repositories. On the old system (Ubuntu 14.04) a pop-up with the title "Unlock private key" appeared for the first use of the key (asking for my passphrase) and I was set for the rest of the session.

Since the update I get the following error:

$ 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.

This is due to the fact that the key has not been added to the ssh-agent (yet). I can do this manually using:

$ ssh-add ~/.ssh/my_key
Enter passphrase for .ssh/my_key:

which is a workaround.

Question

While the above workaround might do the trick and there are options to automate it (see link below), I would prefer to have the old functionality back where I am automatically queried for my passphrase at first use.

What could I (my system) be missing for this to work? I am not 100% about what parts/ programs are involved.

Additional Information

  • Not sure if this is relevant, but I am using LDAP, so I kept the content of my home folder when moving from Ubuntu 14.04 (with Unity) to 16.04 (with KDE).

  • For my email encryption keys, the behavior has not changed and I am asked for the passphrase via pop-up.

  • There is another question dealing with a similar problem. This however deals with a different version and has a different goal (They make it work on console, I would like my pop-up back).

3 Answers 3

4

As already said, add

IdentityFile ~/.ssh/my_key
AddKeysToAgent yes

to your ~/.ssh/config to achieve similar behavior.

If I add (AddKeysToAgent yes) to my local ssh config (~/.ssh/config) the keys are also saved. However the query is in the terminal, which by itself is not bad, but I would like to understand how to get this pop-up back.

The popup in older Ubuntu was coming from gnome-keyring, where you had your key stored. It is obviously not in the KDE version of Ubuntu.

There is no simple way to get the same prompt from the pure OpenSSH. But you might try to experiment with KWallet, which might have similar functionality.

2
  • Thanks, this pointed me in the right direction. According to this and this setting SSH_ASKPASS=/usr/bin/ksshaskpass might do the trick.
    – m00am
    Commented Jun 28, 2017 at 11:34
  • no, it will not do, because ASKPASS is used only if the process does not have TTY (see man ssh).
    – Jakuje
    Commented Jun 28, 2017 at 11:36
0

The default file names for the identity files are the following:

#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519

Add your own file to the /etc/ssh/ssh_config or renaming it should do the trick.

2
  • Thanks and +1. This solves the finding part and already makes my life a lot easier :) If I add (AddKeysToAgent yes) to my local ssh config (~/.ssh/config) the keys are also saved. However the query is in the terminal, which by itself is not bad, but I would like to understand how to get this pop-up back.
    – m00am
    Commented Jun 28, 2017 at 9:51
  • 4
    Do not advise to modify system-wide configuration /etc/ssh/ssh_config. Use ~/.ssh/config.
    – Jakuje
    Commented Jun 28, 2017 at 10:52
0

I would be very surprised the ubuntu upgrade or version has anything to do with it.

it does sounds like a git+ssh problem. it could be unrelated, but I had a similar problem using git via ssh with bitbucket service.

what happened is that I had 2 bitbucket accounts. and both SSH keys loaded into my agent. bitbucket does not permit to reuse the same ssh key for multiple accounts. so you are forced to have two.

when both were loaded into my agent, I was logged into the wrong account and getting the same Permission denied error.

I used ssh-add -d to temporary remove the identity from my agent

then I found out I could configure it in my ssh config properly.

Host bitbucket_account2
  HostName bitbucket.org
  User git
  PreferredAuthentications publickey
  IdentityFile /home/mathieu/.ssh/bitbucket_account2_rsa
  IdentitiesOnly yes
  ControlMaster no

then

git remote remove origin
git remote add origin bitbucket_account2:team/soft.git

have fun

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .