Open reyman opened 3 years ago
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/yubikey-smartcard-challenge-mode-usable-on-remote-ssh/8936/32
Ok i found a weird way to get gpg --card-status
working :
1 - connect to remote initrd ssh
2 - remove all socket ~/crypt-ramfs/.gnupg
2 - pkill gpg-agent
2 - disconnect
3 - reconnect
4 - search the good gpg package with which gpg
5 - run the gpg with good homedir :
/nix/store/gf17pa61cwvf41xggq3q8cv6wrw46jaq-extra-utils/bin/gpg --homedir /crypt-ramfs/.gnupg --card-status
Each time you need to pkill gpg-agent
and rm /crypt-ramfs/gnupg/S*
, disconnect, reconnect when you re running this command... If you don't do that, you have this error :
~ # /nix/store/gf17pa61cwvf41xggq3q8cv6wrw46jaq-extra-utils/bin/gpg --homedir /crypt-ramfs/.gnupg --card-status
gpg: failed to start agent '/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gnupg-2.2.23/bin/gpg-agent': No such file or directory
gpg: can't connect to the agent: No such file or directory
gpg: OpenPGP card not available: No agent running
Works manually to decrypt passphrase, but don't resolve the problem of "No gpg Card to appear...." during initrd boot.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/yubikey-smartcard-challenge-mode-usable-on-remote-ssh/8936/33
Actually on unstable, it seems impossible to forward GPG agent to a remote ssh from a yubikey.
I used this, gpg forwarding, about an hour ago. There might be something complicated about using GPG with luksroot, but there's nothing broken about just forwarding a gpg socket on unstable.
And to reiterate, again, gpg --card-status
is not meant or expected to work with a forwarded gpg socket.
And to reiterate, again,
gpg --card-status
is not meant or expected to work with a forwarded gpg socket.
Hum, i'm only talking about the initrd first stage
and only that, so using a specific env (initrd stage) with very limited capacity, before classic and normal nixos environment with gpg normally configured. To be more clear, this radically different from nixos final stage.
Sorry about that, like multiple people, i'm trying, and i'm not alone.
gpg --card-status
with gpg-agent.socket
forwarding (and not the limited gpg-agent-extra.socket
) seems possible, and there are multiple post on web explaining that, for example : https://blog.alt255.com/post/gpg_forwarding/
I marked this as stale due to inactivity. → More info
Sorry but this is not solved Bot.
Just faced into the similar issue while trying to create a key, and it's horrible. Ok, I'm on nixos-21.05
and can confirm that I see an invalid pinentry path in the gpgconf
's output and also that gpg
starts another version of gpg-agent with no --pinentry-program
flag used by systemd of nixos.
Here is a quick workaround that I am using to generate the damn gpg key:
pinentry
manually, write down the full path to the pinentrylinux
(I used xterm-kitty)$ TERM=linux LANG=C gpg-agent --pinentry-program /nix/store/297r9wmbsd0n51bx155dml93bdirn87p-pinentry-1.1.0/bin/pinentry --daemon /bin/sh
gpg --yes --quick-gen-key 'Me <email@ser.org>' default default never
gpgconf --check-programs
still outputs incorrect path for pinentry, thinking that it is in the gpg's rootJust throwing this out again -- when I walk up to a computer and need to do GPG/SSH stuff, I run gpg-fix
: https://github.com/cole-mickens/nixcfg/blob/063d1b16a7b9bd676805350511a4e9d78ce0d529/pkgs/commands.nix#L56
I basically never encounter this problem anymore as the script ensures the user service is restarted instead of gpg-agent self-daemonizing. It sort of feels like there should be a way to tell gpg-agent to please kindly not, but I haven't looked into it (I'm more interested in soon putting GPG entirely behind me other than for compat)
Describe the bug
Actually on unstable, it seems impossible to forward GPG agent to a remote ssh from a yubikey.
To Reproduce
Install Nixos from liveCD
2 - with ssh support at initrd for decrypting luks
3 - Modify local config to connect on my server with remote forwarding
Found this information for .gnupg configuration into Luksroot.nix at line 124
So after veryfing with
gpgconf --list-dirs
my socket, i configure my local.ssh/config
like that4 - Reboot and try to authenticate with my Yubikey GPG smartcard uing ssh
Failed ..
5- So i remove all the
S*
Socket on remote/crypt-ramfs/.gnupg
and after that i connect with success ...When i check on remote host, in ash using
ps -a
:Ok, there is some problem with created socket at initialization of initrd, but that don't explain why during boot GPG card don't appear and gpg --card-status don't work !
// Trying to debug by trying to run manually
gpg --card-status
1 - on remote, add log to gpg-agent, first kill gpg-agent :
2a - add this into
/crypt-ramfs/.gnupg/gpg-agent.conf
2b - add debug info to
/crypt-ramfs/.gnupg/scdaemon.conf
3 - reload
4 Reconnect with ssh and see nothing happen into log :
6 - Trying to run manually
gpg --card-status
on remoteash
and see the problemsUsing lsof and which i see that running PID for gpg / scadaemon :
which gpg-agent
returnlsof -p PID
of the current runninggpg-agent
returnMy conclusion at this time :
gpg
try to run an inexistantgpg-agent
and not the correctgpg-agent
already loaded into\crypt-ramfs\.gnupg
?Expected behavior
Decrypt my luks filesystem using my gpg smartcard by SSH with GPG remote forwarding
Notify maintainers @marenz2569 @flokli @colemickens
Maintainer information: