Replacing the SSH agent with gpg-agent is a bit harder than what I thought
- Inicie sesión ou rexístrese para enviar comentarios
Hello fellow Trisquel users,
I’m trying to use gpg-agent to replace the ssh agent. I have done a couple of things: neutralize the xdg-autostart ssh-agent, prevent /etc/X11/Xsession from running the ssh-agent, set up .gnupg/sshcontrol and add enable-ssh-support in .gnupg/gpg-agent.conf.
I set SSH_AUTH_SOCK in .bashrc, and open a new terminal: I can now log in via SSH, or start emacs and use tramp!
However, if I don’t work in a new terminal, then SSH_AUTH_SOCK is wrong. I tried setting it in .bashrc, .bash_profile, .profile, and .xsessionrc, but every time it gets overwritten by the time I can use the session. I don’t know what does that thing to me, but it’s very frustrating. Do you have an idea what is going on?
I don't know (I never used this) but I saw https://dev.to/ehuelsmann/ssh-with-gpg-agent-on-systemd-5ddf and https://curiouslynerdy.com/gpg-agent-for-ssh-on-ubuntu/ that give a number of hints.
The hints in the first article are said to be tested on Ubuntu 22.04 on which Trisquel 11 is based, so perhaps it has relevant hints for Trisquel. The second article might be made using a previous Ubuntu version.
> neutralize the xdg-autostart ssh-agent, prevent /etc/X11/Xsession from running the ssh-agent
With your modifications, is ssh-agent still started? On my computer, the parent process of ssh-agent is gnome-keyring-daemon.
Hello! Thanks for the hints. They describe what I have done (I followed the guide in your first link). With a few more debugging printfs around, I can tell you that, when I open the session:
1. .profile is loaded, and the SSH_AUTH_SOCK variable is already correct there;
2. .xsessionrc is loaded, and the SSH_AUTH_SOCK variable is still correct.
Note that while I have this at the top of my .profile, .bashrc is not loaded (!)
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
Anyway, after .xsessionrc is loaded, something else ruins SSH_AUTH_SOCK for my graphical session.
And ssh-agent is not started.