You are not logged in.

#1 2015-06-26 18:08:01

luken
Member
Registered: 2014-06-26
Posts: 37

[SOLVED] Cannot connect to gpg-agent from SOME gnome terminals

I have some magic running around my desktop and need help. I'm using GNOME 3. In my .bash_profile I have:

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

envfile="$HOME/.gnupg/gpg-agent.env"
if [[ -e "$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 SSH_AUTH_SOCK   # enable gpg-agent for ssh

And gpg-agent is genuinely running after login. I added a keyboard shortcut Alt + Ctrl + t that is invoking "gnome-terminal".

And now a magical part. When I'm running "ssh-add" in a terminal invoked by clicking a launcher icon - I'm getting "Could not open a connection to your authentication agent." .

BUT

When I'm invoking terminal by pressing Alt + Ctrl + t - it can connect to it!

I was so confused that I even tried to run terminal from a terminal, by running "gnome-terminal" but a terminal invoked that way also couldn't connect to agent.

Anyone have any ideas what can I do/check to undestand/fix this madness?

Added #1:
Ok I diffed environmental variables of both terminals, and it appears that in those which don't work, SSH_AUTH_SOCK and GPG_AGENT_INFO are missing. But why? :/

Last edited by luken (2015-06-26 19:39:33)

Offline

#2 2015-06-26 19:38:10

luken
Member
Registered: 2014-06-26
Posts: 37

Re: [SOLVED] Cannot connect to gpg-agent from SOME gnome terminals

Ok, so I have no idea why but it appeared that when I was invoking terminals from launcher/gnome it has not been sourcing .bash_profile . I removed this file and instead put in .profile "export SSH_AUTH_SOCK=/run/user/1000/keyring/ssh" (where 1000 is my user id) which file is sourced in any case, and everything is consistent already. One strange thing though - it wasn't needed/was working on my previous rig, with up to date Arch and the same configuration. It baffles me why .bash_profile is now not sourced. Any ideas?

In any case I found a workaround so I'm marking it as solved, but any insights to this are welcome.

Offline

#3 2015-06-26 20:54:52

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

Re: [SOLVED] Cannot connect to gpg-agent from SOME gnome terminals

.bash_profile is sourced for login shells: see the note https://wiki.archlinux.org/index.php/Ba … tion_files


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB