VSCode no access to Nitrokey

I use my Nitrokey mostly for SSH Authentication and signing git commits. That works perfectly fine from the terminal. But I also want to do the same from within VSCode… which I can without issues inside the VSCode terminal, but I have problems with the GUI.

When I open VSCode from the terminal with command code, I can use the GUI button to push to a remote server. But when I open VSCode using my Gnome keybinding executing code command, or the Gnome launcher icon - Pushing to a remote through GUI doesn’t anymore. It doesn’t recognize my key and so authentication fails.

I have the following in my .bashrc:

# SSH Auth with GPG
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
  export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"

And I assume that VSCode is somehow not picking up this environment variable and thus it fails. I already tried to change the keybinding to open vscode to the command bash -c "source ~/.bashrc; exec code" which results in the same issue.

Anyone of you got this working? Help is appreciated. Thanks!

I’m not using it, so it’s a blindshot: Have a look at this issue on how to check its debug log - it should at least show you if the nitrokey is recognised locally. Perhaps setting the mentioned options help the issue too.

Just use env to see the environment variables, dump them to a file and compare them using diff.