Reputation: 508
Is there a way (preferably a simple, concise way) to send an email from the command line in UNIX with multiple encrypted attachments?
This is in a workplace environment, so I am hesitant to install anything.
Upvotes: 1
Views: 3897
Reputation: 16389
Assume you have two encrypted files file1.pgp file2.pgp (edit: uuencode -> uuencode -m)
Tar and mail them
tar cf - file1.pgp file2.pgp | uuencode -m myfile.tar | mailx -s 'test' [email protected]
The recipient will need something to open the tar container: windows 7zip, etc. You can also zip the files. gzip will not work.
echo "file1.pgp file2.pgp" | zip zipfilename -@
cat zipfilename.zip | uunecode -m zipfilename.zip | mailx -s 'test' [email protected]
If the files are not encrypted you can encrypt and password protect with zip
echo "file1.txt file2.txt" | zip zipfilename -@ -P password
This is not secure in the sense that some can see you enter the password with the ps command on the unix box.
edit: Dec 26120120
Upvotes: 1
Reputation: 239051
The command-line tool openssl
is usually already installed on most UNIX-like servers. It is something of a cryptographic swiss-army knife; its openssl smime
utility allows you to create S/MIME standard encrypted and/or signed mail.
Upvotes: 1
Reputation: 80405
I hate to offer this as an answer because it’s as old as Moses and probably even more out of date, but I use the nmh system of commands for this sort of thing.
It’s incredibly abstruse, but you can build most anything you want out of it. It might even already be installed on your system, which I suspect would be a benefit.
I have no doubt there are infinitely many newer, slicker, hipper, and more wonderful systems out there for this sort of thing. I just don’t know them. I’ve got some 25 years worth of accumulated email that I access under this system, and I’ve written dozens of applications on top of it for customized little approaches.
I still answer mail using vi
to edit, and I read mail in a Terminal window. I still have scripts around I used from back before perl
was even invented. That’s how ancient this is. I first started using it in early or mid-80s. I can’t remember anything before it except perhaps /usr/ucb/Mail
. It would be easy to write an sh
or perl
script that glues together MH commands to do exactly what you’re asking for.
I wouldn’t wish MH on anybody else, though. My mom manages to cope with it, but she’s a vi
user herself and has studied more assembly language than I have. Beyond her, I don’t know if I can count a half-dozen friends who still use MH for their mail.
It does have one thing going for it, though: you’ll never, ever, ever get spoofed by anybody trying to dupe you into falling for a phishing exploit, because you always eyeball even HTML mail as plaintext initially (at least that’s how I have it set up), so you immediately see that the links are wacky.
Upvotes: 0