To be an encrypted ninja or not to be...

Its a debate whether or not foreign powers hacked into Hillary Clinton's private email servers. There is consensus however that the private email server was hacked though, and this is precisely how emails can easily get leaked. To solve this sort of problem you can either have Hilary and Hilary's friend's become ninjas at cryptography, have cryptography tools become mainstream and transparent, or have a middle ground solution somehow. For this year's 2017 Hackweek at SUSE and Aaron Swartz day I have worked on a middle ground solution as a proof of concept using GPG, forcing all incoming emails to you to be encrypted, even if you use gmail or yahoo to store your emails. On this post I will explain the motivation for such work, and document how to accomplish this for yourself, should you want to implement this for yourself.


Emails sent to you when you are using popular email servers such as gmail or yahoo get encrypted only on the wire, as they make their way onto email servers hosted by the companies that provide these services. The emails are however stored unencrypted. Likewise for typical private email servers. You are at left at the whims of the security best practices of these companies, and even if you did have your private email server, to get things done right requires substantial work. In fact, even if you used a good company to store your email, you may still face issues with ensuring your email privacy remains outside of the control of intelligence agencies which may argue they should be able to read everyone's email.

Reasons for wanting your emails stored with good cryptography vary but here are a few reasons:

  • You're a politician
  • You're a therapist
  • You're a journalist
  • You're a human rights advocate
  • You just give a damn about privacy

For most people's day to day, the below diagram simplifies and reveals how email transactions work, Exhibit-A:

One solution to this is to have everyone, for example, use encryption tools when crafting and sending emails, Exhibit-B:

This is a bit unrealistic, however for some folks this is possible, for instance if you're a journalist working with very sensitive material. If you fall into one of the categories below you might not be able to get to this point:

  • You're a human rights watch group worker dealing with folks who can't easily become ninjas... 
  • Your're a therapist, who obviously deals with folks who don't even care about what a crypto ninja is
  • You're a politician and just want to encrypt everything
  • You want to open up your email on a certain date and use an escrow to stash your PGP key, such key becomes public after certain date
  • You want to ask company admins to setup a secure and sensible way to forward some company emails to a public mail server safely (say, a way to get work email on public servers)
  • You just care about cryptography
  • You cannot trust your email provider's data store at all
  • You don't want your data to be scraped by the company hosting it

Making cryptography more easily accessible is a much better approach. Such good efforts exists, one example I found was FlowCrypt which lets you uses Public Key Cryptography, however that does mean trying to trust a private key on the plugin store locally. Another effort, which doesn't use Public Key Cryptography is SecureGmail by streak, you encrypt emails using a one way cipher. Both and similar solutions still require some effort or deploying some sort of software on the sender's side.

What I've worked on means as a ninja, or if you have a ninja friend, you get the benefit of having your emails stored on your preferred email server encrypted, provided you can trust a particular middle service provider I'll describe how to set up, and you can get it secured. You end up with the following, Exhibit-C:

To accomplish this we need a middle end system which does the actual encryption for you using your public key. Email providers such as Google, Yahoo, and others won't do this for us today, and they have some reasons not to. By scraping your email they get the ability to provide search facilities, they get to scrape emails as they might legally see fit, and advertise for you. This is how they make money off of storing our emails for free. Using a middle layer to encrypt your email is reflected in the following diagram, Exhibit-D:

One must admin that this shifts trust to a particular server admin who sets this server up,  and to trust the setup to parse and bounce emails to your preferred email server properly. Your emails are still at risk but they are not stored on the middle server if done propery, they are just being piped through. Also, with unencrypted emails even your old emails are at risk, once an email server is compromised all your emails stored on that server are at risk. With a super simple service such as the one I am describing, it would be fairly easy to monitor against attacks and only protect one thing: receive encrypted emails via TLS, encrypt them write away without writing them to disk, and immediately bounce them. Nothing unencrypted lands on disk or storage.

How do I get this?

If you're curious to try it for a few tests cases, you trust me for such tests cases, shoot me an email and I can set you up with an account on my proof of concept email system, I can give you an account on such system, and if you get an email sent to that email address all emails will be immediately bounced back to you, encrypted with your PGP key.

I would not recommend you to use this setup just as-is though, it'd be best to have spam detection be done on your behalf, otherwise it may be possible your email provided's spam detection tool won't pick up spam, and you end up getting tons of spam.

As such, this is just a proof of concept at this point.

How do I replicate your setup?

Even though this uses PGP keys to encrypt data, you'll need to set up an email server with proper TLS certificates for encryption for communication between senders and bouncing emails to email servers. Fortunately letsencrypt can give you a free certificate, it must be renewed (easy to do). The same SSL certificate you get for them for your apache setup can be used for email as well. So first thing you should do is get a DNS name, then get a simple website up with an SSL certificate from letsencrypt.

If you have control over the email server you may not want to give an full shell login account to all users, but just an email alias. I used postfix for my email server, as its easy to setup, and has some hooks we'll use later. So get yourself postfix installed and setup, no need to setup TLS for your first setup. Just get it receiving emails locally first. Once you have that setup, setup the same SSL certificate you used for your apache setup for your postfix configuration. The following is my setup, roughly.

You'll then need to edit /etc/postfix/ and add the following phphook like, and replace your smtp line with the one below as well:

pgphook unix - n n - - pipe flags=F user=www-data argv=/opt/bin/ ${sender} ${size} ${recipient}
smtp inet n - - - - smtpd -o content_filter=pgphook:dummy

Then setup virtual aliases, /etc/postfix/address.txt looks like this: FILTER pgphook:dummy

Add more entries per email address you want to add. After updating it you must run:

postmap /etc/postfix/address.txt

Then its all a matter or just one script and one procmailrc file, and ensuring the script, its gpg directory, and keyring are all owned by the user the email server runs as. That's it.

I stashed the script, procmailrc and gpg directory and keyring for the email server in:

mkdir /opt/mail2pgp/.gnupg
chmod o-rwx /opt/mail2pgp/.gnupg
chmod g-rwx /opt/mail2pgp/.gnupg
sudo chown -R www-data /opt/mail2pgp/

To create a keyring with keys, or update them later with new keys as you update the alias file, and script provided later:

gpg --search-keys hexkeyid
gpg --export --output keyring.gpg
cp keyring.gpg /opt/mail2pgp/keyring.gpg

The script:

You'll also need a MIME preamble, and postfix:

And finally, the procailrc file:

That's it. In fact, you can use the MIME  preamble and postfix and procmailrc file as a template on a system you *don't* have root on to bounce encrypted emails out to you in a much more secure way as well.

Now I'll surely see someone try to hack this server :) and I'm sure they will ;)


Rocky said…
It's very informative Blog, it's more helpful to us thanks for sharing keep it up !!! Here is my site gmail sign out problems
Tuhin said…
keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
digital marketing training in bangalore /
lavanya said…
I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!
I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!Java training in Chennai

Java Online training in Chennai

Java Course in Chennai

Best JAVA Training Institutes in Chennai

Java training in Bangalore

Java training in Hyderabad

Java Training in Coimbatore

Java Training

Java Online Training

ramesh said…

very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.

Azure Training in Chennai

Azure Training in Bangalore

Azure Training in Hyderabad

Azure Training in Pune

Azure Training | microsoft azure certification | Azure Online Training Course

Azure Online Training

CloudLearn ERP said…
You have provided finicky information for a new blogger so it has turned out to be really obliging. Keep up the good work!
Data Science training in Mumbai
Data Science course in Mumbai
SAP training in Mumbai
Ramya said…
Very interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome.You can also check my articles as well.
DevOps Training in Chennai

DevOps Online Training in Chennai

DevOps Training in Bangalore

DevOps Training in Hyderabad

DevOps Training in Coimbatore

DevOps Training

DevOps Online Training
dhinesh said…
Thanks for sharing this wonderful content.its very useful to us.This is incredible,I feel really happy to have seen your webpage.I gained many unknown information, the way you have clearly explained is really fantastic.keep posting such useful information.
Full Stack Training in Chennai | Certification | Online Training Course
Full Stack Training in Bangalore | Certification | Online Training Course

Full Stack Training in Hyderabad | Certification | Online Training Course
Full Stack Developer Training in Chennai | Mean Stack Developer Training in Chennai
Full Stack Training

Full Stack Online Training

devi said…
it’s really nice and meaningful. it’s really cool blog. Linking is very useful have really helped lots of people who visit blog and provide them useful information.
Data Science Training In Chennai

Data Science Online Training In Chennai

Data Science Training In Bangalore

Data Science Training In Hyderabad

Data Science Training In Coimbatore

Data Science Training

Data Science Online Training
tejaswini said…
I am dazzled by the data that you have on this blog. It shows how well you comprehend this science certification
Revathi said…
I feel really happy to have seen your webpage.I am feeling grateful to read gave a nice information for us.please updating more stuff content...keep up!!

Android Training in Chennai

Android Online Training in Chennai

Android Training in Bangalore

Android Training in Hyderabad

Android Training in Coimbatore

Android Training

Android Online Training
prabhu said…
Excellent Blog! I would Thanks for sharing this wonderful content.its very useful to us.I gained many unknown information, the way you have clearly explained is really fantastic.keep posting such useful information.
IELTS Coaching in chennai

German Classes in Chennai

GRE Coaching Classes in Chennai

TOEFL Coaching in Chennai

spoken english classes in chennai | Communication training

360DigiTMG said…
I see some amazingly important and kept up to length of your strength searching for in your on the sitehrdf training course
Bhavana said…
I think I have never watched such online diaries ever that has absolute things with all nuances which I need. So thoughtfully update this ever for us.
360DigiTMGMY said…

Nice work... Much obliged for sharing this stunning and educative blog entry!
hrdf claimable training
Anirban Ghosh said…
You have provided finicky information for a new blogger so it has turned out to be really obliging. Keep up the good work!
SAP training in Kolkata
SAP training Kolkata
Best SAP training in Kolkata
SAP course in Kolkata
CloudLearn ERP said…
I am highly overwhelmed to read this perfect piece of writing. It has really enthused me to read more on this topic.
Data Science training in Mumbai
Data Science course in Mumbai
SAP training in Mumbai

CloudLearn ERP said…
I am astounded by the fact how you have described the entire scenario of the topic. It contains judiciously sound advices.
Data Science training in Mumbai
Data Science course in Mumbai
SAP training in Mumbai

Data Science said…
I am impressed by the information that you have on this blog looking forward for next update thank you.
Data Analytics Course Online 360DigiTMG
devika iangar said…
Super site! I am Loving it!! Will restore again, Im taking your food in like manner, Thanks.
difference between analysis and analytics
360digitmg said…
I am sure that this is going to help a lot of individuals. Keep up the good work. It is highly convincing and I enjoyed going through the entire blog.
data science institute in hyderabad
tejaswini said…
I see some amazingly important and kept up to length of your strength searching for in your on the site
digital marketing course
Farhan.Jee said…
The future of automated cars depends a lot on the processing of the exorbitant amount of data. As estimated, self-driving cars produce around 1 GB data each second, and more than that, they also receive data from other cars around them. data science course syllabus
Cyber Security said…
Nice Information Your first-class knowledge of this great job can become a suitable foundation for these people. I did some research on the subject and found that almost everyone will agree with your blog.
Cyber Security Course in Bangalore
Ashok said…
Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
data science course in India
EXCELR said…
Thanks For sharing a nice post about Course.It is very helpful and useful for science courses
Mike Johnson said…
I advise you to be a ninja, it is cool! You can make some tricks and make video how you are doing it, post on youtube and buy youtube likes from here Lol, it is a joke
Excelr Tuhin said…
keep up the good work. this is an Ossam post. This is to helpful, i have read here all post. i am impressed. thank you. this is our site please visit to know more information
data science training
This comment has been removed by the author.
360DigiTMGNoida said…
As always your articles do inspire me. Every single detail you have posted was great.
data science training in noida
Truly incredible blog found to be very impressive due to which the learners who ever go through it will try to explore themselves with the content to develop the skills to an extreme level. Eventually, thanking the blogger to come up with such an phenomenal content. Hope you arrive with the similar content in future as well.
Digital Marketing training
Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

Digital Marketing training in Bhilai
aishu said…
I read your article it is very interesting and every concept is very clear, thank you so much for sharing. AWS Certification Course in Chennai
360DigiTMG said…
great article!! sharing these type of articles is the nice one and i hope you will share an article on data science.By giving a institute like is one the best institute for doing certified courses
data scientist course
This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..
machine learning courses in aurangabad
Wow, amazing post! Really engaging, thank you.
machine learning course aurangabad
Mallela said…
Thanks for posting the best information and the blog is very marketing institute in hyderabad
360DigiTMG-Pune said…
I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You.
data science certification
UFABET1688 said…
Your site got my attention and shows me different perception for how we should boost our site. This is a really perfect for a new blogger like me who doesn't want their site to be messy with those spammers who don't even read your post but they have the guts to comment in your site. Thanks again. บาคาร่าออนไลน์
360DigiTMG-Pune said…
Excellence blog! Thanks For Sharing, The information provided by you is really a worthy. I read this blog and I got the more information about
artificial intelligence course
senthilpraveen said…
This Blog have relevant information’s and reference links which not get board to the readers.
Digital Marketing Training in Chennai
Digital Marketing Online Course
Digital Marketing Training in Bangalore
Mike Johnson said…
Your article is very interesting and funny! Do you want to make a video for tiktok about it? You can buy tiktok followers for your profile and post other video too. What do you think about it?
Good information you shared. keep posting.
machine learning training in aurangabad
Anyone having a keen interest in artificial intelligence which require analytical knowledge and want to contribute to these fields, MBA in Artificial Intelligence is definitely for you.
lionelmessi said…
Happy to visit your blog, I am by all accounts forward to more solid articles and I figure we as a whole wish to thank such huge numbers of good articles, blog to impart to us.

Data Science Training in Hyderabad
"Very Nice Blog!!!

Please have a look about "
ai courses aurangabad
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing. data scientist course in delhi
This is additionally a generally excellent post which I truly delighted in perusing. It isn't each day that I have the likelihood to see something like this..
data science training

Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

Data Science Course in Bhilai
dataanalytics said…
It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!
data scientist training and placement
Gorish dua said…
Thanks for sharing.
We at Antino Labs believe in redefining and refining our model to suit the industry's requirements. Antino Labs' several years of experience in the market has let us register our global presence. Antino Labs' has the vision to become the world's most trusted partner for digital transformation and we aim to become a brand that defines innovation and the latest technology. We offer clients a one-stop solution for all their interests. Click the below links if you're looking for Web Development Company in Gurgaon, Website Designing Company in Gurgaon, Technology Consulting Services, Ecommerce Account Management Services, Mobile App Development Company in Gurgaonand UI/UX Design Services.
What sets us apart from other security companies is that we put lay a lot of emphasis on personal protection. close protection in UK
We have the latest security gadgets, arms, tracking devices, and all accessories that are necessary to detect threats and protect our clients. This is perhaps the leading reason why we are the first choice for many high-end clients who need protection around the clock.
Edison hope said…
great and nice article lots of information to read...great person keep posting and keep updating guys..thanks to get an approved e-visa electronically linked to your passport via a simple online application form Eligible travelers for Turkey Visa online can apply
Extraordinary blog went amazed with the content that they have developed in a very descriptive manner. This type of content surely ensures the participants to explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.

Data Science Training
Unknown said…
Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.iot course in delhi
Unknown said…
I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, will provide more information on these topics in future articles.
data science course in london
Tom said…
Thank you for this article.. Travelers around the world who wish to travel the Kenya need to apply for Kenya visa through online e visa portal. That offers the fast and secure visa services and offers fast Kenya evisa processing time.
Ramesh Sampangi said…
Nice information. Very useful to all. I am satisfied with your site. Keep sharing more stuff like this. Thanks for sharing this blog with us.
Data Science Course in Hyderabad

Data Science Training in Hyderabad
토토사이트 said…
It's really great. Thank you for providing a quality article. There is something you might be interested in. Do you know 룰렛사이트? If you have more questions, please come to my site and check it out!

Data Science said…
Amazingly by and large very interesting post. I was looking for such an information and thoroughly enjoyed examining this one. Keep posting. An obligation of appreciation is all together for analytics course in gwalior
James said…
It is actually helpful and useful information. Thanks for posting this blog. The traveler who travels to India must know about Indian visa fees.

This is really very nice post you shared, i like the post, thanks for sharing..
cyber security course malaysia
DataCharge said…
Very wonderful informative article. I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks! .
Data Analytics training in Bangalore
Anne Markey said…
This is great and awsome post for me. i loved to read your blog. it's really-really amazing. thanks for inspired me by your blog.Online Garen Store
Buy Golden Jhumka
Buy Online Seeds
Buy Handicrafts Online
Book Resin Planter
Buy ZZ Plant Online India
Buy Bunny Ear Cactus
DataBank said…
Nice to be seeing your site once again, it's been weeks for me. This article which ive been waited for so long. I need this guide to complete my mission inside the school, and it's same issue together along with your essay. Thanks, pleasant share.
Data Science training in Bangalore
data science said…
I truly like your style of blogging. I added it to my preferred's blog webpage list and will return soon…
Unknown said…
Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!best data science course in bhubaneswar
Sell House said…
List with Confidence Real Estate Company all of our agents are long time locals and experts in the local real estate market. Find out about them here.

sell your home in Toronto
home buyer in Toronto
Unknown said…
Great to become visiting your weblog once more, it has been a very long time for me. Pleasantly this article i've been sat tight for such a long time. I will require this post to add up to my task in the school, and it has identical subject along with your review. Much appreciated, great analytics course in ghaziabad
360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

I think this is an informative post and it is very useful and informative. So, I want to thank you for the effort you put into writing this article. India introduces a new air suvidha self declaration form to help stop the spread of COVID-19. Indian self declaration form registration, You can fill online India self declaration form & read online required documents for self declaration form via India visas website.
Unknown said…
I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more. data science course in mysore
Unknown said…
It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it! data science training in kanpur
Cyberz Pc said…
Any creature can look at the WiFi Password Hacker Online section in the diagram and would like to use it for free. Online Wifi Password Hack
Cyberz Pc said…
Deep Dark Love Quotes quotations area unit simply phrases or quotes concerning deep love with such a splash of romance, tranquilly, and joy thrown certain smart live. Dark Love Quotes
slot said…
สำหรับสมาชิกใหม่ ฝากเข้ามาเพียง 29 บาท ก็สามารถรับเครดิตได้เลยฟรีๆ 100 บาท ทำกำไรได้มากมายผ่านเว็บไซต์ PGSLOTGAMES ให้คุณเล่นได้มั่นคงปลอดภัย ทำกำไรได้ตลอด 24 ชั่วโมง สล็อตลิขสิทธิแท้จากค่าย PG SLOT AUTO พีจีสล็อต
PSW550 said…
เล่นสนุกตลอด 24 ชั่วโมง ทำได้ผ่านเว็บไซต์ PGSLOT-AUTOS เล่นง่าย โปรโมชั่นเพียบ ไม่ว่าจะเป็นโปรสมัครสมาชิก โปรโมชั่นแนะนำเพื่อน โปรชั่นฝากทั้งวัน และโปรโมชั่นคืนยอดเสีย ทำกำไรได้ตลอด 24 ชั่วโมง PG SLOT AUTO เล่นได้สบาย รับเครดิตฟรีได้ง่ายดาย มากถึง 1,000 เครดิตฟรีต่อวัน
Jack Bravo said…
I am particularly joyful to appear by these variety of blogs. I am dispensing it with my companions as they are similarly seeking out this type of educational blogs.
url opener
Maddy Crusoe said…
Marvelous details and aspects imparted in this short guide. Getting ready for even more blog posts similar to this one.

umrah packages uk
Unknown said…
Splendid truths and components given out in this shortened blog. Expecting more reports such as this one.
Phuwadon said…
The jackpot is over a hundred thousand. almost one million And the camp we actually pay because we are the number one website in the country of online slots games. No matter how much it is broken, it pays us as a website sent directly from abroad. There are many great activities to play every week. Welcome new members to play ทางเข้าเล่นpg pgslot with us always.
Maya said…
Thanks for writing such a great article! It has posts that are great and helpful. Keep it up.
Breet Pink said…
Thanks for this awesome artilce.
More Details
This very informative and interesting blog.
Security Services
This very informative and interesting blog.
Truck Repair Shop
Sell House said…
This very informative and interesting blog.
property brokerage
What is Website said…
This very informative and interesting blog.
web design company
เรามาเล่นเกมสล็อต PG SLOT-GAME ไปพร้อมกับการหาของทานเล่นไปพร้อม ๆ กันดีกว่ากับค่ายเกมสล็อตออนไลน์ ที่กำลังมาแรงที่สุดในช่วงเวลานี้เรามาเล่นเกมสล็อต pgslot หนึ่งในเกม

Popular Posts