Suppress the passphrase prompt in GPG command

对着背影说爱祢 提交于 2021-02-05 20:18:56

问题


Edited Version

I have a question about GPG, but I write all of the process, maybe it will help someone.

I want to: Suppress the passphrase prompt in GPG command. I don't want to: use -c option (--symmetric).

I have 2 systems Linux and Windows. I want to send the data from Linux to Windows. I want to encrypt the data in Linux and decrypt in Windows.

  • myFileOnLinux.txt is a file on Linux that I want to encrypt.
  • my@Email.com the UID of pair key.
  • myPasswordPhrase is the password phrase.

I installed GPG on both and did the steps:

  1. Generate a pair key in Windows:

    gpg --gen-key
    
  2. Change the key parameter in Windows:

    gpg --edit-key my@Email.com
    
    trust
    5
    expire
    0
    
  3. Export the public keys:

    gpg -a --export my@Email.com > public.key
    
  4. Send the public key to the Linux machine.

  5. Import the public key in Linux.

    gpg --import public.key
    
  6. Change the trust parameter in Linux

    gpg --edit-key my@Email.com
    
    trust
    5
    
  7. Encrypt a file in Linux

    gpg --output output.enc --encrypt --recipient my@Email.com myFileOnLinux.txt
    
  8. Send the encrypted file to Windows.

  9. Decrypt the file.

    gpg --batch --passphrase "myPasswordPhrase" -d -o test.dec output.enc
    

In Windows with a popup window it asked me the Passphrase again. How can I avoid it?


回答1:


After a lot of digging I found this command which disables the entry prompt on windows(works also for *nix systems):

--pinentry-mode=loopback

The full command would be:

gpg --pinentry-mode=loopback --passphrase  "PASSWORD" -d -o "PATH\TO\OUTPUT" "PATH\TO\FILE.gpg"


来源:https://stackoverflow.com/questions/49072403/suppress-the-passphrase-prompt-in-gpg-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!