Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PGP support during transfer #416

Open
debilin opened this issue Oct 14, 2023 · 7 comments
Open

Add PGP support during transfer #416

debilin opened this issue Oct 14, 2023 · 7 comments
Assignees

Comments

@debilin
Copy link

debilin commented Oct 14, 2023

Please allow to encrypt/decrypt using PGP during transfer from host1 to host2. So for example, I need to pull from host1, decrypt the email using my PGP key and then upload to host2. The emails on host2 are unencrypted.

@gilleslamiral gilleslamiral self-assigned this Oct 15, 2023
@gilleslamiral
Copy link
Member

Do you know a command decrypt to do it on the command line, with an rfc822 email as input, like this;

cat email_encrypted.txt | decrypt > email_decrypted.txt

@debilin
Copy link
Author

debilin commented Oct 15, 2023

@gilleslamiral Let me try it and see. But can we run this in between imapsync transfer process? I need this to be automated along with imapsync.

@gilleslamiral
Copy link
Member

gilleslamiral commented Oct 15, 2023

Let me try it and see.

First, you have to find it. decrypt is a name I just made up.

Can we run this in between imapsync transfer process?

Yes, with the --pipemess option. Here are two dummy examples:

imapsync ... --pipemess cat 

imapsync ... --pipemess '(cat|cat)'

All email messages transferred by imapsync will go through these commands cat or cat | cat

https://imapsync.lamiral.info/README
...

     --pipemess     cmd  : Apply this cmd command to each message content
                           before the copy.
     --pipemess     cmd  : and this one, etc.
                           With several --pipemess, the output of each cmd
                           command (STDOUT) is given to the input (STDIN)
                           of the next command.
                           For example,
                           --pipemess cmd1 --pipemess cmd2 --pipemess cmd3
                           is like a Unix pipe:
                           "cat message | cmd1 | cmd2 | cmd3"

@debilin
Copy link
Author

debilin commented Oct 17, 2023

First, you have to find it. decrypt is a name I just made up.

I see 🤦‍♂️ I thought it's an existing program on my system. I will look around and report back

@gilleslamiral
Copy link
Member

I searched and found nothing doing the job completely.
The command gpg can decipher the email from STDIN to STDOUT, which is excellent for --pipemess, but only the encrypted part, the other parts are thrown away.

You're bound to write the tool if you really need it.

@debilin
Copy link
Author

debilin commented Oct 18, 2023

That's what I found as well. gpg --decrypt almost works nicely. Thanks for your help. I will search around more to see if there is anything I can do beside coding it myself.

@debilin debilin closed this as completed Oct 18, 2023
@gilleslamiral
Copy link
Member

https://imapsync.lamiral.info/TODO
...

SUGGESTED 2023_10_14 by debilin
https://github.com/imapsync/imapsync/issues/416
Add PGP support during transfer
Write a tool to keep STDIN as is like the cat command except for the pgp parts
where gpg is invoked to do its job.

gilles@petite:~ 73$ cat toto.txt | LANG= gpg --decrypt  --batch --no-tty  --passphrase=$P  --allow-multiple-messages  2>/dev/null 
toto

gilles@petite:~ 74$ cat toto.txt
From: gilles@lflflf
Subject: rrrrr


-----BEGIN PGP MESSAGE-----
Version: GnuPG v1

hQEOA+8dQNKixMtCEAP/Qr4TlMPXn72GOKQoPS4Hke3Bt8i5/Vp05u2sJrJopfV1
MorlhUeMbpZwBEsT+FzQYe0QrBdeH9bg43pjS5UJ83PK970By0hUQWXWprRRcmYC
XE3DtDXzaWsUguB79PGWNDP+OaUH2PaaapLUw6X3aePkFIk+CjNFBR961yAchUED
/2hSA6exyLuzWq9BUvU7Iqvei3l+6wZAnWnFbUNloqOR6H92lPTFVhSQj/TK3uxa
WMlb19SMvXuSMWxaIhCmTKD9uXV3sXptshMSkne7OGTu/RWdwEQhQCQdmMBnBz0e
9btnB/3brQXchfvsjL6XCowUBzB+w3mdcXeM3Hps7KJ/0kABl8L3KDw0tS92KpGo
dtiykQebYl/et8gfqemxzOwvakaAzattU75BAPwcNJo2jU9fMdjDxgGntUweJOpT
z0rF
=bya7
-----END PGP MESSAGE-----

@gilleslamiral gilleslamiral reopened this Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants