You are not logged in.

#1 2013-08-17 09:52:07

replax
Member
Registered: 2011-02-12
Posts: 90

GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

Hi!

I am using gpg-agent to handle my gpg keys and wanted it to handle my ssh keys too, since it is running anyway.
it works perfectly fine with gpg keys, my pinentry program is pinentry-qt4 , upon request that window pops up for me to enter my passphrase.
as window manager i use awesome wm.

however, when i try to use my ssh key, e.g. for github, no pinentry program pops up and in xterm it looks like:

[me@mybox dotfiles]$ git push origin master

it seems that is is waiting for my passphrase input but it isnt asking for it. neither does it accept it.
when i quit my WM, i see that it executed the pinentry program directly in my tty1, to which i do not have access while running my WM.

my gpg-agent.conf:

me@mybox ~/.gnupg> cat gpg-agent.conf 
default-cache-ttl 300
max-cache-ttl 7200
pinentry-program /usr/bin/pinentry-qt4

how do i get gpg-agent to respect my pinentry choice for my ssh keys as well?

thanks for your time smile!

Offline

#2 2013-08-18 01:33:23

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

How are you starting gpg-agent?

Did you follow the instructions for configuring this in the wiki? One reason I ask is that they worked for me except that the fact that I use kde complicated things and I had to adapt them somewhat. But that shouldn't be a problem if you are just using a wm.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-08-18 10:12:29

replax
Member
Registered: 2011-02-12
Posts: 90

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

i start gpg-agent in my xinitrc like this:

eval $(gpg-agent --daemon --enable-ssh-support) &

and have this in /etc/profile.d/gpg-agent.sh according to the wiki entry

#!/bin/sh
envfile="${HOME}/.gnupg/gpg-agent.env"
if test -f "$envfile" && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
    eval "$(cat "$envfile")"
else
    eval "$(gpg-agent --daemon --enable-ssh-support --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO

it works fine with gpg-keys' pinentry, ssh keys are making trouble... do you have any further idea? smile

thanks!

Offline

#4 2013-08-18 14:23:07

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

I use this

$ cat /etc/kde/env/gpg-agent-startup.sh 
#!/bin/sh
# see https://wiki.archlinux.org/index.php/SSH_Keys

GPG_AGENT=/usr/bin/gpg-agent
## Run gpg-agent only if not already running, and available
if [ -x "${GPG_AGENT}" ] ; then

  # check validity of GPG_SOCKET (in case of session crash)
  GPG_AGENT_INFO_FILE=${HOME}/.gpg-agent-info
  if [ -f "${GPG_AGENT_INFO_FILE}" ]; then
    GPG_AGENT_PID=`cat ${GPG_AGENT_INFO_FILE} | grep GPG_AGENT_INFO | cut -f2 -d:`
    GPG_PID_NAME=`cat /proc/${GPG_AGENT_PID}/comm`
    if [ ! "x${GPG_PID_NAME}" = "xgpg-agent" ]; then
      rm -f "${GPG_AGENT_INFO_FILE}" 2>&1 >/dev/null
    else
       GPG_SOCKET=`cat "${GPG_AGENT_INFO_FILE}" | grep GPG_AGENT_INFO | cut -f1 -d: | cut -f2 -d=`
       if ! test -S "${GPG_SOCKET}" -a -O "${GPG_SOCKET}" ; then
         rm -f "${GPG_AGENT_INFO_FILE}" 2>&1 >/dev/null
       fi
    fi
    unset GPG_AGENT_PID GPG_SOCKET GPG_PID_NAME SSH_AUTH_SOCK
  fi

  if [ -f "${GPG_AGENT_INFO_FILE}" ]; then
    eval "$(cat "${GPG_AGENT_INFO_FILE}")"
    eval "$(cut -d= -f 1 "${GPG_AGENT_INFO_FILE}" | xargs echo export)"
    export GPG_TTY=$(tty)
  else
    eval "$(${GPG_AGENT} -s --enable-ssh-support --daemon --pinentry-program /usr/bin/pinentry-qt4 --write-env-file)"
  fi

fi

I think I could probably use the /etc/profile.d location but when I first set it up, kde was already running gpg-agent so I adapted its file. Later, I uninstalled the thing which does that in kde and just kept my own customised version.

Are you sure that your xinitrc isn't starting a second gpg-agent?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#5 2013-08-19 14:55:47

replax
Member
Registered: 2011-02-12
Posts: 90

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

As it writes an env file and checks if it is there before launchen (i think so) it runs it only once:
ps aux | grep gpg gives:

[me@mybox ~]$ ps aux | grep gpg
me         323  0.0  0.0  13384   408 ?        Ss   14:38   0:00 gpg-agent --daemon --enable-ssh-support --write-env-file /home/me/.gnupg/gpg-agent.env
me        5642  0.0  0.0  10684  1076 pts/0    S+   16:53   0:00 grep gpg

do your ssh keys work well with the gpg agent?

Offline

#6 2013-08-19 23:10:20

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

My ssh keys work fine this way, yes. I get the qt dialogue pop up asking for a password and then I don't need to give the password again (for a while). Works great with ssh, sshfs, scp, unison over ssh - anything I've tried involving ssh, to be honest. Not sure about GUI stuff as I don't remember ever testing it that way but everything I've tried has worked great. (Famous last words - sure it'll all stop working in a second - but up til now, at any rate...)

Is there not more of the gpg-agent command? That seems to be incomplete.

There should be 3 environmental variables in the info file: GPG_AGENT_INFO, SSH_AUTH_SOCK, SSH_AGENT_PID. These should all show up in printenv, for example, as should GPG_TTY. At least that's what I have.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#7 2013-08-20 00:42:11

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

You could also use keychain; it handles both pgp and ssh keys and, going by the snippets posted here, is a lot less convoluted to set up...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#8 2013-08-20 00:56:16

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

But then you have to run ssh-agent, gpg-agent and keychain, don't you?

I think too it will depend on how often you want it to ask for a password. Personally, I wouldn't like to only be asked once per boot. I suppose you could always kill it on suspend or something but then it starts to get really complex. Of course, this might not be an issue on a desktop in a relatively secure home or office set up.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#9 2013-08-20 01:04:40

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

cfr wrote:

But then you have to run ssh-agent, gpg-agent and keychain, don't you?

No. ssh-agent is installed as part of openssh and keychain runs it. gpg-agent is not a dependency.

cfr wrote:

I think too it will depend on how often you want it to ask for a password. Personally, I wouldn't like to only be asked once per boot. I suppose you could always kill it on suspend or something but then it starts to get really complex. Of course, this might not be an issue on a desktop in a relatively secure home or office set up.

You can set the timeout in your conf file:

# Cache settings
default-cache-ttl 6000
default-cache-ttl-ssh 6000
max-cache-ttl 6000
max-cache-ttl-ssh 6000

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#10 2013-08-20 01:13:02

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

What I meant was that the OP would be running ssh-agent and gpg-agent as well as keychain. I realise keychain handles those processes but I thought the idea was to have a single agent handling both ssh and gpg keys using pinentry-qt4.

EDIT: Good to know about the timeouts, though - that wasn't obvious to me from the wiki.

Last edited by cfr (2013-08-20 01:13:36)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#11 2013-08-20 02:18:44

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

Oh, I see what you mean. Yes. But other than a process running in the background, it hardly constitutes an overhead and given the simplicity of the setup, well worth it, IMO.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#12 2013-08-20 02:24:13

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

I like the gpg-agent method but then it just worked for me. That is, I had to work through the wiki and adapt it a little but then it just went. Since KDE was starting gpg-agent itself at the time, I had to do something to stop a second agent being started and adapting KDE's startup script seemed as good a way as any. However, updates had a nasty habit of wiping my adaption and I got fed up replacing it so I just got rid of the package and kept my config in place.

Hence the history of my setup made it the simplest solution at any decision point but not necessarily the sanest one if I were to have planned it that way from scratch!


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#13 2014-03-29 23:08:46

jeroentbt
Member
From: .be
Registered: 2014-03-29
Posts: 25

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

@replax
Did you manage to solve this or are you using keychain now?

Offline

#14 2016-02-05 17:35:06

replax
Member
Registered: 2011-02-12
Posts: 90

Re: GPG-AGENT "ignoring" pinentry program? wrong pinentry app for ssh-keys

I did not manage to solve this issue unfortunately. Somehow gpg throws strange errors for me and I am considering an OS reinstall..... I dont know how else to fix it, as no one else seemingly has that problem. Reinstalling gpg has not helped it seems.

Offline

Board footer

Powered by FluxBB