Using secrets (keyring) in ssh session.

I use a remote server as a primary development platform using ssh to login. One problem I ran into was not having access to a keyring. gnome-keyring-daemon is actually launched and associated with a dbus session but is not usable by default.

I finally found a simple method to setup my ssh session to be associated with that gnome and dbus session while also unlocking the keyring. I used a bash function unlock, but you could also embed this in a tmux startup config – I will probably do this eventually.

unlock () {
    eval $(echo "GETPIN" | pinentry --ttyname $TTY 2> /dev/null | awk '/^D /{print $2;}' | gnome-keyring-daemon --unlock --replace --components=ssh,secrets)