0

I try to automate gpg keys import. In bash shell I have following line:

$ echo "$KEY_PASSWORD" | gpg --batch --passphrase-fd 0 --yes --import <(echo "$KEY" | base64 -d)

This is not working in sh shell. How can I pass password and import key in one line in sh shell?

  • Use a regular file or a named pipe if you have to. If this is not a shell question but a GPG one, edit your question to explicitly state that and we will reopen it. – oguz ismail Dec 30 '20 at 10:31
  • In this case, I don't think you need named pipes (as in the duplicate). Try `echo "$KEY" | base64 -d | { exec 3<&0; echo "$KEY_PASSWORD" | gpg --batch --passphrase-fd 0 --yes --import /dev/fd/3; }` (Note: depending on your OS, /dev/fd/3 might have to be changed to some local equivalent.) – Gordon Davisson Dec 30 '20 at 10:47
  • @GordonDavisson, This is exactly for what I was looking for. Thank you! – Oleksandr Dievri Dec 30 '20 at 17:44

0 Answers0