Hello,
I'm experiencing same issues found in this thread https://github.com/keepassxreboot/keepassxc/issues/3683
For my daily work I have to input multiple times the same password to login into machines and I'd like to let keepass add/remove these creds into my ssh-agent to make things easier.
I'm running Artix OpenRC with bspwm and gnome-terminal with zsh. When I open a new terminal is not a fork of the main one but an independent one.
I launch ssh-agent and the variables are exported correctly for that terminal spawn, but not the other ones, so the variables are not being exported globally really, this affects other software in this case KepassXC.
I been trying multiple ways to launch ssh-agent as suggested on the github link above, last one being from .xinitrc using these lines.
pgrep -x ssh-agent > /dev/null || ssh-agent
export SSH_AUTH_SOCK
Still the variables are not being globally exported, maybe I'm missing/doing something wrong? Hope you might have some clue on how to tackle this.
Thanks in advance!
It should work if you put that in your .zshrc.
That's been tried before and unfortunately it doesn't work... See below output from a recent spawned terminal
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXVzShNC/agent.21132; export SSH_AUTH_SOCK;
SSH_AGENT_PID=21133; export SSH_AGENT_PID;
echo Agent pid 21133;
❯ echo $SSH_AUTH_SOCK
Of course, KeePassXC still complaints about it.
Setting environment variable
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
in .zprofile(if using zsh) or bash_profile (if using bash) could make it work. Then relogin
confirm variable is working usng command:
printenv | grep SSH_AUTH
then run
ssh-agent -D -a $SSH_AUTH_SOCK
In above command -D run command in foreground mode
Now open keepassxc
So now the environment variable seems to be properly exported but keepass still complains. Below relevant outputs
❯ cat -p .zprofile
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
cat -p .xinitrc
pgrep -x ssh-agent > /dev/null || ssh-agent -D -a $SSH_AUTH_SOCK
❯ printenv | grep SSH_AUTH
SSH_AUTH_SOCK=/run/user/1000/ssh-agent.socket
❯ ps ux | grep ssh-agent
2486 0.0 0.0 6188 448 ? Ss 20:03 0:00 ssh-agent
Also attaching screenshot from keepass, now it finds the SSH_AUTH_SOCK value but still doesn't work despite ssh-agent running
@gege29 run ssh-agent using my command then check
Edit : There can be a possibility that .xinitrc is read before .zprofile
put environment variable in .xprofile and also remove -D from ssh-agent , it is not suitable for this situation
.xinitrc looking like this now
pgrep -x ssh-agent > /dev/null || ssh-agent -a SSH_AUTH_SOCK
.xprofile looking like this
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
Weird interaction happening, when I logoff and login again, then startx, ssh-agent doesn't launch. Then I manually trigger the command ssh-agent -a SSH_AUTH_SOCK and I get following output
unix_listener: cannot bind to path SSH_AUTH_SOCK: Address already in use
Then I manually check the environment varibale using
printenv | grep SSH_AUTH
but I get blank output.
Same interaction happening after reboot (just in case the unix socket could be cleaned)
This is driving me crazyy :D
pgrep -x ssh-agent > /dev/null || ssh-agent -a SSH_AUTH_SOCK put this in .zshrc
Recheck .xinitrc SSH_AUTH_SOCK should be $SSH_AUTH_SOCK
Apologies for taking so long...
Well, added
pgrep -x ssh-agent > /dev/null || ssh-agent -a SSH_AUTH_SOCK
to .zshrc
This shows when opening a new shell, also followed by output from manually checking the env.
unix_listener: cannot bind to path SSH_AUTH_SOCK: Address already in use
❯ echo $SSH_AUTH_SOCK
❯ printenv | grep SSH_AUTH
blank ::)
@gege29 also check
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
exist in .zprofile
you did mistake
pgrep -x ssh-agent > /dev/null || ssh-agent -a $SSH_AUTH_SOCK
It's working! Wow, thanks for bearing and staying patient with me.
So happy to have this working up, making my life easier now.
For those interested lurking the internet for possible same issue, here you have the final outputs from my dot files
❯ cat .zshrc | grep ssh-agent
pgrep -x ssh-agent > /dev/null || ssh-agent -a $SSH_AUTH_SOCK
❯ cat .zprofile| grep ssh-agent
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
❯ cat .xinitrc | grep ssh-agent
pgrep -x ssh-agent > /dev/null || ssh-agent -a $SSH_AUTH_SOCK
After this, you need to configure the override on KeePassXC' ssh-agent configuration menu with
/run/user/1000/ssh-agent.socket
or whatever output comes from
❯ printenv | grep SSH_AUTH
Thanks again! :) Marking this as resolved.