I'm trying to setup gpg-agent forwarding in order to use pass (https://www.passwordstore.org) via ssh.
gpg version 2.2.9 both on local and remote hosts, installed by instructions: https://gist.github.com/vt0r/a2f8c0bcb1400131ff51
extra-socket /home/mickey/.gnupg/S.gpg-agent.remote
echo RELOADAGENT | gpg-connect-agent
gpg --export -a mickey > mickey.gpg
echo "test" | gpg2 --encrypt -r mickey > out.gpg
scp *.gpg REMOTE_HOST:
ssh -R /run/user/1002/gnupg/S.gpg-agent:/home/mickey/.gnupg/S.gpg-agent.remote -o "StreamLocalBindUnlink=yes" REMOTE_HOST
gpg --import mickey.gpg
gpg --edit-key mickey
trust 5 quit
gpg --decrypt -v out.gpg
gpg: public key is FED6243A3325C554 gpg: connection to agent is in restricted mode gpg: using subkey FED6243A3325C554 instead of primary key 9E2ED69A02554504 gpg: using subkey FED6243A3325C554 instead of primary key 9E2ED69A02554504 gpg: encrypted with 2048-bit RSA key, ID FED6243A3325C554, created 2018-07-23 "mickey" gpg: public key decryption failed: Inappropriate ioctl for device gpg: decryption failed: No secret key
So, agent socket forwarding is working, seems there are some problems with pinentry program. Could not find anything that worked for me in google.
Tried to add pinentry-program /usr/bin/pinentry-tty
to gpg-agent.conf, new error:
gpg: public key decryption failed: Invalid IPC response gpg: decryption failed: No secret key
ANSWER: “inappropriate ioctl for device” is the error string for the ENOTTY error. It used to be triggerred primarily by attempts to configure terminal properties (e.g. echo mode) on a file descriptor that was no terminal (but, say, a regular file), hence ENOTTY.
gpg-agent is a daemon to manage secret (private) keys independently from any protocol. It is used as a backend for gpg and gpgsm as well as for a couple of other utilities. The agent is automatically started on demand by gpg , gpgsm , gpgconf , or gpg-connect-agent .
It happens when GPG is confused where to read input from. Simply configuring it to look for input from tty (the terminal connected to standard input) fixes it:
export GPG_TTY=$(tty)
This method does not work when you are inside an LXC container. Instead, add this to ~/.gnupg/gpg.conf
:
use-agent pinentry-mode loopback
Then add this to ~/.gnupg/gpg-agent.conf
allow-loopback-pinentry
Then restart the agent with echo RELOADAGENT | gpg-connect-agent
.
(source)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With