In my dotfiles I have the following setup to make ssh connections using my gpg key:
.bash_profile:
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
.gnupg/gpg-agent.conf:
enable-ssh-support
default-cache-ttl 600
max-cache-ttl 7200
and calling ssh-add -l shows me my correspondig gpg key.
This does obviously not translate into tramp/eshell.
I tried setting the SSH_AUTH_SOCK variable inside .config/emacs/eshell/profile:
(let ((ssh_auth_sock (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))
(setenv "SSH_AUTH_SOCK" ssh_auth_sock))
but this does not work and ssh-add -l only displays the error
Error connecting to agent: No such file or directory
What is the correct way of getting this setup working inside tramp/eshell?
SSH_AUTH_SOCKvariable in the shell? Does it have a newline at the end of it? Does the socket filename on disk have a newline at the end of its name? – db48x Feb 10 '22 at 01:32/run/user/1000/gnupg/S.gpg-agent.ssh– Reza Feb 11 '22 at 09:09ls $SSH_AUTH_SOCKinto eshell? – db48x Feb 11 '22 at 15:23~ $ ls $SSH_AUTH_SOCK /run/user/1000/gnupg/S.gpg-agent.ssh : No such file or directory– Reza Feb 13 '22 at 16:40SSH_AUTH_SOCKhas a space after it, or it has a newline and StackExchange mangled it because this is a comment rather than an answer. Either way, this is the source of your problem. – db48x Feb 13 '22 at 16:46SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh ssh-add -land it is working, what can I do to prevent eshell from inserting a newline into my env var? – Reza Feb 13 '22 at 21:41