Coder Social home page Coder Social logo

openpgpit's Introduction

openpgpit

Node.js script to encrypt an email to PGP/Mime format using OpenPGP.js. Inspired by the following guide: https://perot.me/encrypt-specific-incoming-emails-using-dovecot-and-sieve and the following associated script: https://github.com/mikecardwell/gpgit

###Requirements

apt-get install nodejs
apt-get install npm
npm install util
npm install openpgp
npm install fs

###Usage: pgp.js [location of public key]

###Example: The following command will pipe the file mail into pgp.js and the encrypted pgp/mime mail format will be output to stdout.

cat mail | pgp.js [location of public key]

###Dovecot intergration to encrypt all incoming emails ####Debian 8.1 x64 Install nodejs and npm

apt-get install nodejs
apt-get install npm
ln -s /usr/bin/nodejs /usr/local/bin/node

Clone the openpgpit repository

cd /usr/local/src
git clone https://github.com/Enclavet/openpgpit/
chmod +x /usr/local/src/openpgpit/pgp.js

Install dependencies

npm install util
npm install fs
npm install openpgp

Copy/Upload your public key to your user's home directory

cp public.key /home/<user>/public.key

Setup extprograms for sieve in dovecot

vi /etc/dovecot/dovecot.conf

Look for the following and change:

plugin {
  sieve = /var/mail/sievescript/%n/.dovecot.sieve
  sieve_dir = /var/mail/sievescript/%n/scripts/
  sieve_before = /etc/dovecot/global_script/
  sieve_plugins = sieve_extprograms
  sieve_extensions = +vnd.dovecot.filter
  sieve_filter_bin_dir = /etc/dovecot/sieve-filter
}

Create the dovecot sieve-filter directory and place the wrapper script

mkdir /etc/dovecot/sieve-filter
chown vmail:mail /etc/dovecot/sieve-filter
vi /etc/dovecot/sieve-filter/openpgpjswrapper

Paste the following:

#!/bin/bash

myvar=$(cat); echo "${myvar}" | /usr/local/src/openpgpit/pgp.js $1

Make the script executable

chmod +x /etc/dovecot/sieve-filter/openpgpjswrapper

Create the sieve rule

vi /var/mail/sievescript/<userid>/scripts/managesieve.sieve

Paste the following:

require ["fileinto", "vnd.dovecot.filter"];
# rule:[Encryption]
if true
{
        filter "openpgpjswrapper" "/home/<userid>/public.key";
        fileinto "INBOX";
}

Restart dovecot

/etc/init.d/dovecot restart

Finished!

openpgpit's People

Contributors

enclavet avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.