├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── ascii_art ├── diamond.txt ├── eff.txt ├── micah.txt └── trollwot.txt ├── ascii_sign ├── bruteforce_keyid ├── download_strong_set ├── fake_sign ├── lib ├── README.md ├── monkeysphere-0.35 │ ├── .gitignore │ ├── .pc │ │ ├── .quilt_patches │ │ ├── .quilt_series │ │ ├── .version │ │ └── applied-patches │ ├── COPYING │ ├── Changelog │ ├── Makefile │ ├── README │ ├── debian │ │ ├── NEWS │ │ ├── changelog │ │ ├── compat │ │ ├── control │ │ ├── copyright │ │ ├── gbp.conf │ │ ├── monkeysphere.dirs │ │ ├── monkeysphere.postinst │ │ ├── monkeysphere.postrm │ │ ├── monkeysphere.prerm │ │ ├── rules │ │ └── source │ │ │ └── format │ ├── etc │ │ ├── cron.hourly │ │ │ └── monkeysphere │ │ ├── monkeysphere-authentication.conf │ │ ├── monkeysphere-host.conf │ │ └── monkeysphere.conf │ ├── examples │ │ ├── crontab │ │ ├── ssh_config │ │ └── sshd_config │ ├── man │ │ ├── man1 │ │ │ ├── monkeysphere.1 │ │ │ ├── openpgp2ssh.1 │ │ │ └── pem2openpgp.1 │ │ ├── man7 │ │ │ └── monkeysphere.7 │ │ └── man8 │ │ │ ├── monkeysphere-authentication.8 │ │ │ └── monkeysphere-host.8 │ ├── packaging │ │ ├── macports │ │ │ └── Portfile │ │ └── slackware │ │ │ └── README │ ├── src │ │ ├── monkeysphere │ │ ├── monkeysphere-authentication │ │ ├── monkeysphere-authentication-keys-for-user │ │ ├── monkeysphere-host │ │ ├── openpgp2ssh │ │ ├── pem2openpgp │ │ ├── share │ │ │ ├── checkperms │ │ │ ├── common │ │ │ ├── defaultenv │ │ │ ├── keytrans │ │ │ ├── m │ │ │ │ ├── gen_subkey │ │ │ │ ├── import_subkey │ │ │ │ ├── keys_for_userid │ │ │ │ ├── ssh_proxycommand │ │ │ │ ├── subkey_to_ssh_agent │ │ │ │ ├── update_authorized_keys │ │ │ │ └── update_known_hosts │ │ │ ├── ma │ │ │ │ ├── add_certifier │ │ │ │ ├── diagnostics │ │ │ │ ├── list_certifiers │ │ │ │ ├── remove_certifier │ │ │ │ ├── setup │ │ │ │ └── update_users │ │ │ └── mh │ │ │ │ ├── add_name │ │ │ │ ├── add_revoker │ │ │ │ ├── diagnostics │ │ │ │ ├── import_key │ │ │ │ ├── publish_key │ │ │ │ ├── revoke_key │ │ │ │ ├── revoke_name │ │ │ │ └── set_expire │ │ └── transitions │ │ │ ├── 0.23 │ │ │ ├── 0.28 │ │ │ └── README.txt │ ├── tests │ │ ├── README │ │ ├── basic │ │ ├── common │ │ ├── etc │ │ │ ├── monkeysphere │ │ │ │ └── monkeysphere-authentication.conf │ │ │ └── ssh │ │ │ │ └── sshd_config │ │ ├── home │ │ │ ├── admin │ │ │ │ └── .gnupg │ │ │ │ │ ├── pubkey.gpg │ │ │ │ │ ├── pubring.gpg │ │ │ │ │ ├── random_seed │ │ │ │ │ ├── secring.gpg │ │ │ │ │ └── trustdb.gpg │ │ │ └── testuser │ │ │ │ ├── .gnupg │ │ │ │ ├── gpg.conf │ │ │ │ ├── pubring.gpg │ │ │ │ ├── random_seed │ │ │ │ ├── secring.gpg │ │ │ │ └── trustdb.gpg │ │ │ │ ├── .monkeysphere │ │ │ │ ├── authorized_user_ids │ │ │ │ └── monkeysphere.conf │ │ │ │ └── .ssh │ │ │ │ ├── askpass │ │ │ │ ├── config │ │ │ │ └── proxy-command │ │ ├── keytrans │ │ └── openssl.cnf │ └── utils │ │ ├── build-freebsd-distinfo │ │ ├── build-macports-portfile │ │ └── preparing-release └── python-gnupg-0.3.3 │ ├── LICENSE │ ├── PKG-INFO │ ├── README │ ├── gnupg.py │ ├── setup.py │ └── test_gnupg.py └── trollwot.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.pyc 3 | homedir* 4 | bruteforce_keyid_data* 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/gnupg"] 2 | path = lib/gnupg 3 | url = https://github.com/micahflee/trollwot_gnupg.git 4 | [submodule "lib/python-gnupg"] 5 | path = lib/python-gnupg 6 | url = https://github.com/isislovecruft/python-gnupg.git 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Trolling the Web of Trust 2 | ========================= 3 | 4 | This repository is the home of scripts related to my OHM2013 talk. 5 | 6 | To get started, clone the repo and submodules: 7 | 8 | git clone https://github.com/micahflee/trollwot.git 9 | cd trollwot 10 | git submodule init 11 | git submodule update 12 | 13 | Install some dependencides. On a Debian-based distro you do this: 14 | 15 | sudo apt-get install python-psutil monkeysphere 16 | 17 | Install the gnupg build dependencies. On a Debian-based distro you do this: 18 | 19 | sudo apt-get build-dep gnupg 20 | 21 | Build the modified gnupg. 22 | 23 | cd lib/gnupg 24 | ./configure 25 | make 26 | 27 | ASCII sign a PGP key 28 | -------------------- 29 | 30 | ascii_sign is a script that takes a filename and a target key id as input. It downloads the target key, then generates a new PGP for each line in the file and signs the target key with the new keys. Essentially, it lets you sign any key with ASCII art. 31 | 32 | For example, check out my key: http://pool.sks-keyservers.net:11371/pks/lookup?op=vindex&search=0x5C17616361BD9F92422AC08BB4D25A1E99999697 33 | 34 | ASCII sign a key like this: 35 | 36 | ./ascii_sign [ASCII_ART_FILENAME] [KEYID] 37 | 38 | If you're ASCII signing a key with multiple user IDs, you'll have to press "y" to verify you want to sign all user IDs for each line. 39 | 40 | Add fake sigs to a PGP key 41 | -------------------------- 42 | 43 | fake_sign.py is a script that takes a name, email address, and target key id as input. It creates a new key with that name and email, and uses it to sign the target key. Usage: 44 | 45 | ./fake_sign [NAME] [EMAIL] [KEYID] 46 | 47 | Brute force PGP key ID 48 | ---------------------- 49 | 50 | bruteforce_keyid.py is a modified version of the keytrans script, that comes with [monkeysphere](http://web.monkeysphere.info/) that adds new functionality to do the brute forcing. Since: 51 | 52 | fingerprint = hash(public_key) 53 | public_key = timestamp + public_key_data 54 | 55 | Therefore: 56 | 57 | fingerprint = hash(timestamp + public_key_data) 58 | 59 | So the script works like this: 60 | 61 | * It generates a 4096 bit RSA key 62 | * It sets the creation timestamp to now 63 | * It goes in a loop calculating the fingerprint and looking for collisions, decrementing the timestamp until the timestamp is from 3 years ago 64 | * If it didn't find it, it starts over by generating a new 4096 bit RSA key 65 | 66 | On my laptop it compares about 12,000 fingerprints per second. Here's how to use it: 67 | 68 | ./bruteforce_keyid [USERID] [KEYID] 69 | 70 | *Note: The keys generated by this script are likely cryptographically secure, but sadly they don't seem to actually work to do crypto operations.* For example: 71 | 72 | [user@gpgvm ~]$ gpg --homedir vanity_homedir/ --list-secret-keys 73 | vanity_homedir//secring.gpg 74 | --------------------------- 75 | sec 4096R/22222222 2014-03-10 76 | uid Micah Lee 77 | 78 | sec 4096R/CCCCCCCC 2014-01-12 79 | uid Micah Lee 80 | 81 | sec 4096R/D15C0FAD 2014-01-26 82 | uid Micah Lee 83 | 84 | sec 4096R/D15EA5ED 2014-02-07 85 | uid Micah Lee 86 | 87 | sec 4096R/FAC701D5 2014-05-01 88 | uid Micah Lee 89 | 90 | sec 4096R/FEE1DEAD 2014-02-08 91 | uid Micah Lee 92 | 93 | sec 4096R/00000001 2013-12-05 94 | uid Micah Lee 95 | 96 | [user@gpgvm ~]$ gpg --homedir vanity_homedir/ --default-key D15EA5ED --detach-sign test 97 | gpg: no default secret key: unusable secret key 98 | gpg: signing failed: unusable secret key 99 | 100 | If anyone wants to fix this problem, pull requests are welcome. 101 | 102 | -------------------------------------------------------------------------------- /ascii_art/diamond.txt: -------------------------------------------------------------------------------- 1 | ┃ __________________ ┃ 2 | ┃ * / \x / \x /xx\ /x\ ┃ 3 | ┃ /x x\/ *x \/xx \/ * \ ┃ 4 | ┃ /____/\____/\____/\____\ ┃ 5 | ┃ \ /\ / / ┃ 6 | ┃ \ / \ / / ┃ 7 | ┃ \ \ / * / ┃ 8 | ┃ \ \ / / ┃ 9 | ┃ \ \ / / ┃ 10 | ┃ \ \ / / ┃ 11 | ┃ \ \/ / ┃ 12 | ┃ \* /\ / ┃ 13 | ┃ \ / \ / ┃ 14 | ┃ \ / * ┃ 15 | ┃ \ / ┃ 16 | ┃ \/ ┃ 17 | ┃ Signatures Are Forever ┃ 18 | ┃ ~ trollwot ┃ 19 | -------------------------------------------------------------------------------- /ascii_art/eff.txt: -------------------------------------------------------------------------------- 1 | ................................................................................ 2 | ........................................... 777777777777777.................... 3 | ....................................... 77777~~~~~~~~~~~~~77777 ................ 4 | ....................................?7777~~~~~~~~~~~~~~~~~~~~~777 .............. 5 | ..................................7777~~~~~~~~~~~~~~~~~~~~~~~~~~:777............ 6 | .................................777~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~777.......... 7 | .777777777777777777777777777777777~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~77 ........ 8 | .77.........................................~~~~~+77777~~~~~~~~~~~~~~~777....... 9 | .77.........................................~~~~~+77777~~~~~~~~~~~~~~~~77 ...... 10 | .77.........................................~~~~~+77~~~~~~~~~~~~~~~~~~~~77 ..... 11 | .77.........................................~~~~~+77~~~~~~~~~~~~~~~~~~~~~77 .... 12 | .77...............777777 7 77~~~~~~~~~~~~~~~~~~~~+7777~~~~~~~~~~~~~~~~~~~~7 .... 13 | .77...............77......77~~~~~~~~~~~~~~~~~~~~~+7777~~~~~~~~~~~~~~~~~~~~+7 ... 14 | .77...............77.....777~~~~~~~~~~~~~~~~~~~~~+77~~~~~~~~~~~~~~~~~~~~~~~77... 15 | .77...............77777777 ~~~~~~~~~~~~~~~~~~~~~~+77~~~~~~~~~~~~~~~~~~~~~~~77 .. 16 | .77........................................~~~~~~+77~~~~~~~~~~~~~~~~~~~~~~~~77.. 17 | .77........................................~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~77.. 18 | .77........................................~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~77.. 19 | .77........................................~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~7 .. 20 | .77...............777777777~~~~~~~~~~~~~~~~~~~~~~+77777~~~~~~~~~~~~~~~~~~~~~7 .. 21 | .77...............77..... 7~~~~~~~~~~~~~~~~~~~~~~+77~~~~~~~~~~~~~~~~~~~~~~~777.. 22 | .77...............77.....777~~~~~~~~~~~~~~~~~~~~~+77~~~~~~~~~~~~~~~~~~~~~~~7 ... 23 | .77...............77...... 7~~~~~~~~~~~~~~~~~~~~~+77~~~~~~~~~~~~~~~~~~~~~~=7 ... 24 | .77...............77777777 7~~~~~~~~~~~~~~~~~~~~+7 77~~~~~~~~~~~~~~~~~~~~7 .... 25 | .77.........................................~~~~~+77~~~~~~~~~~~~~~~~~~~~~777.... 26 | .77.........................................~~~~~+77~~~~~~~~~~~~~~~~~~~~77 ..... 27 | .77.........................................~~~~~+77~~~~~~~~~~~~~~~~~~~77 ...... 28 | .77.........................................~~~~~+77~~~~~~~~~~~~~~~~~~777....... 29 | .777777777777777777777777777777777~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~77 ........ 30 | ................................~777~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~77 .......... 31 | ..................................7777~~~~~~~~~~~~~~~~~~~~~~~~~~~777,........... 32 | ....................................7777?~~~~~~~~~~~~~~~~~~~~~7777,............. 33 | ....................................... 777 7~~~~~~~~~~~~~777777................ 34 | ..........................................,777777 7777777777.................... 35 | ................................................................................ 36 | ................................................................................ 37 | -------------------------------------------------------------------------------- /ascii_art/micah.txt: -------------------------------------------------------------------------------- 1 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 2 | :::::::::::::::::::::::::::::::::::::::,:::::::::::,:::::::::,,,,::,:,:::,:::,,, 3 | :::::::::::::,,,:,,,,,,,,,,,,,,,,,,,,,,:,,,:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 4 | ,,:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 5 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,$I,:$I$7$+:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 6 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,I=~Z8D88OO+Z+::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 7 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::OO8888OOD88D8O$,:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 8 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,:$OO8O8OO888888DO8O7Z:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 9 | ,,,,,,,,,,,,,,,,,,,,,,..,,,,?88888OZI77ZO8D888DZOO7=.,.......................... 10 | ,,.........................,=Z888$I+?$ZZO887$O88O$=~:........................... 11 | ............................O888$+++==++7O$Z$ZZZ88$,............................ 12 | ...........................,8Z8OI==========++?7O88Z,............................ 13 | ...........................+Z8OO?+========+++?IZO8O,............................ 14 | ...........................$$8DZ+7$Z7$+===+=+?7O88~............................. 15 | ............................7?87$Z?ZOZOI+ZOOI?Z88O.............................. 16 | ............................=~$++==+?=~++I+?IOZ8O............................... 17 | .............................~=+==~7$Z~=I8+==?IO................................ 18 | .............................~:7===+=+=~?I+==+IZ................................ 19 | ..............................~$?+I?IIIZO7??+?7................................. 20 | ...............................7I+??+??II7I?+7~................................. 21 | ...............................$7?I=??I+$????$.................................. 22 | ................................$$7I=?++?II7$=.................................. 23 | ................................?O$$I?+??7$87................................... 24 | .........................=.7887I?=O87?I?7Z8ODO88................................ 25 | ........................88888?+$+=+IOD8D8D877~88888O............................ 26 | ,,,..............:,,,,,Z88888$$~+==+=++?I?$,ZDDDDD88Z........................... 27 | :~~:~:::~::~::~~~~~~~:88DD88DD$N+?===+??+$$=8DD8DDDDDD:,,...................,::: 28 | ~~~~=~~~~~~~~~~:~~~888DDDDDDDDDDDDZ7.,,,ZDDDDDDDDDDDDDDDDD?,:::::::::::::::::::~ 29 | ~~~~~~~~~~~~~~~~DDDDDDDDDDDDDNDDDNDD?=ODNDDDDDDDDDDDDDDDDDDDD~~:::~~:~~~~~:~~~~~ 30 | ??????????II?I?DDDDDDDDDDDDDDDDDDDDDD8DDDDDDDDDDDDDDDDDDDDDDDD??????+?++++++?+++ 31 | ++++++++++++++DDDDDDDDDDDDDDDNDDDDDDDODDDDDDDDDDDDDNDDDDDDDDDD8=~====~===~===~== 32 | +++++=++===++DDDDDDDDDDDDDDNDDDDDDDDD8DDDDD$DZ=,7$=77ODDDDDDDDD====~=====+++==+= 33 | ==+==+=?+===ZDDDDDDDDDDDDDDDDDNNDNNNDDNDNDD?DNDD8O?I$ONNNNNNNDDD=+~~===+++===+=+ 34 | ++++=+++====NDDDDDDDDDDDNNDDDDNNDNNNN8NDNND?DDDDDDOO88NNNNNNNNNN+==:=:~::~~~~~~= 35 | ==~~======~DDDDNDDDDDDDDNNNNNNNNNNNNN8NNNNDDDNDNN?OO8$NNNNNNNNNNI=~~~=~~:::::~~= 36 | ==~=+==+=~=DDDDDDDDNDDDNNNNNNNNNNNNNNNNNNNNDZDNND8NNNNNNNNNNNNNNN~::~~~~:~~:~:~~ 37 | =~=++=+=~:?DDDDDDDDNNNDDNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN=~~~~~:~=:=~~~~ 38 | =~+~==?+~=DNDDNNDDDNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNO~:::=++==~~=== 39 | =+==~==+=+DNDNNNDDDNNNNNNNNNNNNNNNNNNNNNNNNNNMMMNNMMNNNNNNNNNNNNNN===+I+++=+==?~ 40 | ===++++==?DNNNNNNDNNNNNNNNNNNNNNNNNNNNNNNNNNNMMMMMMMMNNNMNNNNNNNNN:~~~:::====+== 41 | ??II?+I?IIDDNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNMMMMMMMMMMNMMMMMNNNNNN7=I+=~=~~~~=:? 42 | +==+++I=+DNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNMMMMMMMMMMMMMMMMMMMNNNNNN~=++?===?I?== 43 | ++==+=I+=DNNNNNNNNNMNNNNNNNNNNNNNNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMNNN+I++=?7I??+++ 44 | +=+====~+NNNNNNNNNNMNNNNNNNNNNNNNNNNNNNNNNMMMMMMMMMMMMMMMMMMMMMMNNM?$==?+?=?I7?+ 45 | 7I?I+++?IDNNNNNNNNNNNNNNNNNNNNNNNNNNN8NNNNMMMMMMMMMMMMMMMMMMMMMMMMNNI7??III7~=+I 46 | +?=+++++DNNNNNNNNNMNNNNNNNNNNNNNNNNNNONNNNMMMMMMMMMMMMMMMMMMMMMMMMMN+I+77?I+?7?= 47 | ?II7I?$ZNNNNNNNNMNNNNNNNNNNNNNNNNNNNNZNNNNMMMMMMMMMMMMMMMMMMMMMMMMMN777$I=?+7777 48 | 7Z77$$7IMNNNNNNNNNNMNNNNNNNNNMNNNNNNN~NNNNMMMMMMMMMMMMMMMMMMMMMMMMMN77??~?7$I++? 49 | 77II77?INNNNNNNNMMNNNNNNNNNNNMNNNNNNNONNNNNMMMMMMMMMMMMMMMMMMMMMMMMMN?+7?I7I+?7+ 50 | 7I$I777NNNNNNNNNNNMMNNNNNNNNNMNNNNNNN8NNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMM+77II$7+= 51 | -------------------------------------------------------------------------------- /ascii_art/trollwot.txt: -------------------------------------------------------------------------------- 1 | ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ 2 | ┃╺┳╸┏━┓┏━┓╻ ╻ ╻┏┓╻┏━╸ ╺┳╸╻ ╻┏━╸ ╻ ╻┏━╸┏┓ ┏━┓┏━╸ ╺┳╸┏━┓╻ ╻┏━┓╺┳╸┃ 3 | ┃ ┃ ┣┳┛┃ ┃┃ ┃ ┃┃┗┫┃╺┓ ┃ ┣━┫┣╸ ┃╻┃┣╸ ┣┻┓ ┃ ┃┣╸ ┃ ┣┳┛┃ ┃┗━┓ ┃ ┃ 4 | ┃ ╹ ╹┗╸┗━┛┗━╸┗━╸╹╹ ╹┗━┛ ╹ ╹ ╹┗━╸ ┗┻┛┗━╸┗━┛ ┗━┛╹ ╹ ╹┗╸┗━┛┗━┛ ╹ ┃ 5 | ┃ ~ Observe. Hack. Make. 2013 ~ ┃ 6 | ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ 7 | -------------------------------------------------------------------------------- /ascii_sign: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys, subprocess, io 4 | cwd = sys.path[0] 5 | 6 | sys.path.append(cwd+'/lib/python-gnupg-0.3.3') 7 | import gnupg 8 | 9 | class TrollWoT_ASCIISign: 10 | def __init__(self, filename, target_keyid, homedir): 11 | self.target_keyid = keyid 12 | self.homedir = homedir 13 | self.keyserver_url = "http://pool.sks-keyservers.net:11371/pks/lookup?op=vindex&search=0x{0}".format(keyid) 14 | self.fingerprints = [self.target_keyid] 15 | 16 | self.gpg = gnupg.GPG(gnupghome=homedir, gpgbinary=cwd+'/lib/gnupg/g10/gpg', verbose=False) 17 | 18 | # download target key 19 | print 'Downloading key {0} from pool.sks-keyservers.net'.format(keyid) 20 | self.recv_key(self.target_keyid) 21 | 22 | # generate new keys 23 | self.gen_keys_and_sign(filename) 24 | 25 | # show fingerprints with gpg 26 | subprocess.Popen(['gpg', '--homedir', self.gpg.gnupghome, '--list-sigs', self.target_keyid]).wait() 27 | 28 | def gen_keys_and_sign(self, filename): 29 | fingerprints_to_sign = [] 30 | 31 | userids = open(filename, 'r').read().strip().split('\n') 32 | if len(userids) > 50: 33 | print "This ASCII art is more than 50 lines. I think that's a bit much, don't you?" 34 | sys.exit(); 35 | 36 | for userid in open(filename, 'r').read().strip().split('\n'): 37 | fingerprint = self.gen_key(userid) 38 | fingerprints_to_sign.append(fingerprint) 39 | self.fingerprints.append(fingerprint) 40 | 41 | for fingerprint in fingerprints_to_sign: 42 | self.sign_key(fingerprint) 43 | 44 | def gen_key(self, userid): 45 | print 'Generating key with userid: {0}'.format(userid) 46 | input = self.gpg.gen_key_input(name_real = userid, key_length = 4096) 47 | input_lines = input.split('\n') 48 | input = '' 49 | for line in input_lines: 50 | if 'Name-Comment' not in line and 'Name-Email' not in line: 51 | input += line+'\n' 52 | key = self.gpg.gen_key(input) 53 | return key.fingerprint 54 | 55 | def sign_key(self, signing_fingerprint): 56 | keyid = signing_fingerprint[-8:] 57 | print 'Signing key {0} with key {1}'.format(self.target_keyid, keyid) 58 | subprocess.Popen(['gpg', '--homedir', self.gpg.gnupghome, '--yes', '--default-key', keyid, '--sign-key', self.target_keyid]).wait() 59 | 60 | def recv_key(self, fingerprint): 61 | keyid = fingerprint[-8:] 62 | print 'Receiving key {0} from pool.sks-keyservers.net'.format(keyid) 63 | subprocess.Popen(['gpg', '--homedir', self.gpg.gnupghome, '--keyserver', 'pool.sks-keyservers.net', '--recv-keys', keyid]).wait() 64 | 65 | if __name__ == '__main__': 66 | # arguments 67 | if len(sys.argv) != 3: 68 | print 'Usage: {0} [ascii_art.txt] [keyid]'.format(sys.argv[0]) 69 | sys.exit() 70 | filename = sys.argv[1] 71 | keyid = sys.argv[2] 72 | 73 | ascii_sign = TrollWoT_ASCIISign(filename, keyid, homedir=cwd+'/homedir_ascii_sign') 74 | -------------------------------------------------------------------------------- /download_strong_set: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | I started writing this, and then quickly realized it would take a really long 5 | to actually download the whole strong set this way. Then I began searching for 6 | how to sync from key servers, which lead me to regular static key server dumps: 7 | 8 | ftp://ftp.prato.linux.it/pub/keyring/ - Generated every Wednesday 9 | http://keys.niif.hu/keydump/ - Generated every Monday 10 | http://key-server.de/dump - Generated every Friday 11 | ftp://key-server.de/dump (anonymous) - Generated every Friday 12 | http://keyserver.borgnet.us/dump - Generated every Sunday 13 | 14 | Right now this script is in a semi-broken state, but I decided to leave it 15 | here anyway. 16 | """ 17 | 18 | import sys, time, subprocess 19 | cwd = sys.path[0] 20 | 21 | sys.path.append(cwd+'/lib/python-gnupg') 22 | import gnupg 23 | 24 | class TrollWoT_DownloadWoT: 25 | def __init__(self, gpg, keyserver = 'pool.sks-keyservers.net'): 26 | self.gpg = gpg 27 | self.keyserver = keyserver 28 | 29 | self.imported_keyids = [] 30 | 31 | keys = self.gpg.list_keys() 32 | fingerprints = [] 33 | for key in keys: 34 | fingerprints.append(key['fingerprint']) 35 | self.add_keyids(fingerprints) 36 | print 'already have {0} keys in keyring'.format(len(self.imported_keyids)) 37 | 38 | def download(self, keyids): 39 | keyids_to_recv = [] 40 | for keyid in keyids: 41 | if keyid not in self.imported_keyids: 42 | keyids_to_recv.append(keyid) 43 | 44 | print '* downloading {0} keyids: {1}'.format(len(keyids_to_recv), keyids_to_recv) 45 | res = self.gpg.recv_keys(self.keyserver, ''.join(keyids_to_recv)) 46 | self.add_keyids(res.fingerprints) 47 | 48 | sig_keyids = self.list_sigs(res.fingerprints) 49 | if len(sig_keyids) > 0: 50 | self.download(sig_keyids) 51 | 52 | def add_keyids(self, fingerprints): 53 | for fp in fingerprints: 54 | keyid = fp[-16:] 55 | if keyid not in self.imported_keyids: 56 | self.imported_keyids.append(keyid) 57 | 58 | def list_sigs(self, fingerprints): 59 | keyids = [] 60 | for fp in fingerprints: 61 | keyids.append(fp[-16:]) 62 | keyids = ' '.join(keyids) 63 | 64 | sig_keyids = [] 65 | gpg_output = subprocess.check_output('gpg --homedir {0} --with-colons --fixed-list-mode --list-sigs {1}'.format(self.gpg.homedir, keyids), shell=True) 66 | for line in gpg_output.split('\n'): 67 | if line[0:4] == 'sig:': 68 | parts = line.split(':') 69 | keyid = parts[4] 70 | userid = parts[8] 71 | if userid != '[User ID not found]': 72 | sig_keyids.append(keyid) 73 | return sig_keyids 74 | 75 | if __name__ == '__main__': 76 | start_time = time.time() 77 | 78 | print 'Download the strong set, starting with 5C17616361BD9F92422AC08BB4D25A1E99999697' 79 | gpg = gnupg.GPG(homedir=cwd+'/homedir_download_strong_set', verbose=False) 80 | 81 | download_wot = TrollWoT_DownloadWoT(gpg) 82 | download_wot.download(['5C17616361BD9F92422AC08BB4D25A1E99999697']) 83 | 84 | end_time = time.time() 85 | time_diff = int(end_time - start_time) 86 | print '{0} keys imported, took {1} seconds'.format(len(download_wot.imported_keyids), time_diff) 87 | 88 | -------------------------------------------------------------------------------- /fake_sign: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys, subprocess, io 4 | cwd = sys.path[0] 5 | 6 | sys.path.append(cwd+'/lib/python-gnupg-0.3.3') 7 | import gnupg 8 | 9 | class TrollWoT_FakeSign: 10 | def __init__(self, name, email, keyid, homedir): 11 | self.gpg = gnupg.GPG(gnupghome=homedir, gpgbinary=cwd+'/lib/gnupg/g10/gpg', verbose=False) 12 | fingerprints = [keyid] 13 | 14 | # download target key 15 | print 'Downloading key {0} from pool.sks-keyservers.net'.format(keyid) 16 | self.recv_key(keyid) 17 | 18 | # generate new key 19 | fingerprint = self.gen_key(name, email) 20 | fingerprints.append(fingerprint) 21 | 22 | # sign target key 23 | self.sign_key(fingerprint, keyid) 24 | 25 | # show fingerprints with gpg 26 | subprocess.Popen(['gpg', '--homedir', self.gpg.gnupghome, '--list-sigs', keyid]).wait() 27 | 28 | def gen_key(self, name, email): 29 | print 'Generating key with userid: {0} <{1}>'.format(name, email) 30 | input = self.gpg.gen_key_input(name_real = name, name_email = email, key_length = 4096) 31 | input_lines = input.split('\n') 32 | input = '' 33 | for line in input_lines: 34 | if 'Name-Comment' not in line: 35 | input += line+'\n' 36 | key = self.gpg.gen_key(input) 37 | return key.fingerprint 38 | 39 | def sign_key(self, signing_fingerprint, target_fingerprint): 40 | signing_keyid = signing_fingerprint[-8:] 41 | target_keyid = target_fingerprint[-8:] 42 | print 'Signing key {0} with key {1}'.format(target_keyid, signing_keyid) 43 | subprocess.Popen(['gpg', '--homedir', self.gpg.gnupghome, '--yes', '--default-key', signing_keyid, '--sign-key', target_keyid]).wait() 44 | 45 | def recv_key(self, fingerprint): 46 | keyid = fingerprint[-8:] 47 | print 'Receiving key {0} from pool.sks-keyservers.net'.format(keyid) 48 | subprocess.Popen(['gpg', '--homedir', self.gpg.gnupghome, '--keyserver', 'pool.sks-keyservers.net', '--recv-keys', keyid]).wait() 49 | 50 | if __name__ == '__main__': 51 | # arguments 52 | if len(sys.argv) != 4: 53 | print 'Usage: {0} [name] [email] [keyid]'.format(sys.argv[0]) 54 | sys.exit() 55 | name = sys.argv[1] 56 | email = sys.argv[2] 57 | keyid = sys.argv[3] 58 | 59 | TrollWoT_FakeSign(name, email, keyid, homedir=cwd+'/homedir_fake_sign') 60 | 61 | -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | gnupg 2 | ===== 3 | 4 | This is a fork of gnupg 1.4.13 where I removed all the entropy from key generation. It generates keys really quickly, but they're all insecure. 5 | 6 | python-gnupg 7 | ============ 8 | 9 | This is the gnupg python module that Isis maintains. It has extra features. 10 | 11 | python-gnupg-0.3.3 12 | ================== 13 | 14 | This is the original unmodified python-gnupg 0.3.3. 15 | 16 | 17 | monkeysphere-0.35 18 | ================= 19 | 20 | A copy of monkeysphere from the debian wheezy source repo. I'm using it specifically for it's keytrans tool. 21 | 22 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/.pc/.quilt_patches: -------------------------------------------------------------------------------- 1 | debian/patches 2 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/.pc/.quilt_series: -------------------------------------------------------------------------------- 1 | series 2 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/.pc/.version: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/.pc/applied-patches: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/.pc/applied-patches -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Makefile for monkeysphere 4 | 5 | # © 2008-2010 Daniel Kahn Gillmor 6 | # Licensed under GPL v3 or later 7 | 8 | MONKEYSPHERE_VERSION = `head -n1 Changelog | sed 's/.*(\([^-]*\)).*/\1/'` 9 | 10 | # these defaults are for debian. porters should probably adjust them 11 | # before calling make install 12 | ETCPREFIX ?= 13 | ETCSUFFIX ?= 14 | PREFIX ?= /usr 15 | MANPREFIX ?= $(PREFIX)/share/man 16 | LOCALSTATEDIR ?= /var/lib 17 | 18 | # nothing actually needs to be built now. 19 | all: 20 | 21 | debian-package: 22 | git buildpackage -uc -us 23 | 24 | # don't explicitly depend on the tarball, since our tarball 25 | # (re)generation is not idempotent even when no source changes. 26 | freebsd-distinfo: 27 | ./utils/build-freebsd-distinfo 28 | 29 | macports-portfile: 30 | ./utils/build-macports-portfile 31 | 32 | clean: 33 | # clean up old monkeysphere packages lying around as well. 34 | rm -f monkeysphere_* 35 | 36 | # this target is to be called from the tarball, not from the git 37 | # working dir! 38 | install: all installman 39 | mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/sbin 40 | mkdir -p $(DESTDIR)$(PREFIX)/share/monkeysphere/m $(DESTDIR)$(PREFIX)/share/monkeysphere/mh $(DESTDIR)$(PREFIX)/share/monkeysphere/ma $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions 41 | mkdir -p $(DESTDIR)$(ETCPREFIX)/etc/monkeysphere 42 | mkdir -p $(DESTDIR)$(PREFIX)/share/doc/monkeysphere 43 | printf "Monkeysphere %s\n" $(MONKEYSPHERE_VERSION) > $(DESTDIR)$(PREFIX)/share/monkeysphere/VERSION 44 | install src/monkeysphere $(DESTDIR)$(PREFIX)/bin 45 | sed -i 's:__SYSSHAREDIR_PREFIX__:$(PREFIX):' $(DESTDIR)$(PREFIX)/bin/monkeysphere 46 | install src/monkeysphere-host $(DESTDIR)$(PREFIX)/sbin 47 | sed -i 's:__SYSSHAREDIR_PREFIX__:$(PREFIX):' $(DESTDIR)$(PREFIX)/sbin/monkeysphere-host 48 | install src/monkeysphere-authentication $(DESTDIR)$(PREFIX)/sbin 49 | sed -i 's:__SYSSHAREDIR_PREFIX__:$(PREFIX):' $(DESTDIR)$(PREFIX)/sbin/monkeysphere-authentication 50 | install src/monkeysphere-authentication-keys-for-user $(DESTDIR)$(PREFIX)/share/monkeysphere 51 | install -m 0644 src/share/common $(DESTDIR)$(PREFIX)/share/monkeysphere 52 | install -m 0644 src/share/defaultenv $(DESTDIR)$(PREFIX)/share/monkeysphere 53 | sed -i 's:__SYSCONFDIR_PREFIX__:$(ETCPREFIX):' $(DESTDIR)$(PREFIX)/share/monkeysphere/defaultenv 54 | sed -i 's:__SYSDATADIR_PREFIX__:$(LOCALSTATEDIR):' $(DESTDIR)$(PREFIX)/share/monkeysphere/defaultenv 55 | install -m 0755 src/share/checkperms $(DESTDIR)$(PREFIX)/share/monkeysphere 56 | install -m 0755 src/share/keytrans $(DESTDIR)$(PREFIX)/share/monkeysphere 57 | ln -sf ../share/monkeysphere/keytrans $(DESTDIR)$(PREFIX)/bin/pem2openpgp 58 | ln -sf ../share/monkeysphere/keytrans $(DESTDIR)$(PREFIX)/bin/openpgp2ssh 59 | install -m 0744 src/transitions/* $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions 60 | sed -i 's:__SYSSHAREDIR_PREFIX__:$(PREFIX):' $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions/0.23 61 | sed -i 's:__SYSSHAREDIR_PREFIX__:$(PREFIX):' $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions/0.28 62 | install -m 0644 src/transitions/README.txt $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions 63 | install -m 0644 src/share/m/* $(DESTDIR)$(PREFIX)/share/monkeysphere/m 64 | install -m 0644 src/share/mh/* $(DESTDIR)$(PREFIX)/share/monkeysphere/mh 65 | install -m 0644 src/share/ma/* $(DESTDIR)$(PREFIX)/share/monkeysphere/ma 66 | install -m 0644 Changelog $(DESTDIR)$(PREFIX)/share/doc/monkeysphere 67 | install -d $(DESTDIR)$(PREFIX)/share/doc/monkeysphere/examples 68 | install -m 0644 examples/* $(DESTDIR)$(PREFIX)/share/doc/monkeysphere/examples 69 | install -m 0644 etc/monkeysphere.conf $(DESTDIR)$(ETCPREFIX)/etc/monkeysphere/monkeysphere.conf$(ETCSUFFIX) 70 | install -m 0644 etc/monkeysphere-host.conf $(DESTDIR)$(ETCPREFIX)/etc/monkeysphere/monkeysphere-host.conf$(ETCSUFFIX) 71 | install -m 0644 etc/monkeysphere-authentication.conf $(DESTDIR)$(ETCPREFIX)/etc/monkeysphere/monkeysphere-authentication.conf$(ETCSUFFIX) 72 | 73 | installman: 74 | mkdir -p $(DESTDIR)$(MANPREFIX)/man1 $(DESTDIR)$(MANPREFIX)/man7 $(DESTDIR)$(MANPREFIX)/man8 75 | gzip -n man/*/* 76 | install man/man1/* $(DESTDIR)$(MANPREFIX)/man1 77 | install man/man7/* $(DESTDIR)$(MANPREFIX)/man7 78 | install man/man8/* $(DESTDIR)$(MANPREFIX)/man8 79 | gzip -d man/*/* 80 | gzip -d $(DESTDIR)$(MANPREFIX)/man1/monkeysphere.1.gz 81 | sed -i 's:__SYSCONFDIR_PREFIX__:$(ETCPREFIX):' $(DESTDIR)$(MANPREFIX)/man1/monkeysphere.1 82 | gzip -n $(DESTDIR)$(MANPREFIX)/man1/monkeysphere.1 83 | gzip -d $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-host.8.gz 84 | sed -i 's:__SYSCONFDIR_PREFIX__:$(ETCPREFIX):' $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-host.8 85 | sed -i 's:__SYSDATADIR_PREFIX__:$(LOCALSTATEDIR):' $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-host.8 86 | gzip -n $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-host.8 87 | gzip -d $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-authentication.8.gz 88 | sed -i 's:__SYSCONFDIR_PREFIX__:$(ETCPREFIX):' $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-authentication.8 89 | sed -i 's:__SYSDATADIR_PREFIX__:$(LOCALSTATEDIR):' $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-authentication.8 90 | gzip -n $(DESTDIR)$(MANPREFIX)/man8/monkeysphere-authentication.8 91 | 92 | # this target depends on you having the monkeysphere-docs 93 | # repo checked out as a peer of your monkeysphere repo. 94 | releasenote: 95 | ../monkeysphere-docs/utils/build-releasenote 96 | 97 | test: test-keytrans test-basic 98 | 99 | test-basic: 100 | MONKEYSPHERE_TEST_NO_EXAMINE=true ./tests/basic 101 | 102 | test-keytrans: 103 | MONKEYSPHERE_TEST_NO_EXAMINE=true ./tests/keytrans 104 | 105 | .PHONY: all tarball debian-package freebsd-distinfo clean install installman releasenote test 106 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/README: -------------------------------------------------------------------------------- 1 | The Monkeysphere Project 2 | ------------------------ 3 | 4 | The Monkeysphere project's goal is to extend OpenPGP's web of trust to 5 | new areas of the Internet to help us securely identify each other 6 | while we work online. 7 | 8 | Specifically, monkeysphere currently offers a framework to leverage 9 | the OpenPGP web of trust for OpenSSH authentication. 10 | 11 | In other words, it allows you to use secure shell as you normally do, 12 | but to identify yourself and the servers you administer or connect to 13 | with your OpenPGP keys. OpenPGP keys are tracked via GnuPG, and 14 | monkeysphere manages the known_hosts and authorized_keys files used by 15 | OpenSSH for authentication, checking them for cryptographic validity. 16 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/NEWS: -------------------------------------------------------------------------------- 1 | monkeysphere (0.23-1) unstable; urgency=low 2 | 3 | * There has been a major interface and data refactoring. Please see the 4 | man pages for details. Major changes are listed here: 5 | * For end users: monkeysphere-ssh-proxycommand is no more. 6 | its functionality has been folded into monkeysphere as a subcommand. 7 | So if you are currently using: 8 | ssh -oProxyCommand='monkeysphere-ssh-proxycommand %h %p' 9 | please use instead: 10 | ssh -oProxyCommand='monkeysphere ssh-proxycommand %h %p' 11 | * For sysadmins: monkeysphere-server has been split into 12 | monkeysphere-host (for publishing the ssh host key of your machine) 13 | and monkeysphere-authentication (for setting up your machine to 14 | authenticate users via the OpenPGP Web of Trust) 15 | * For too-curious sysadmins: the layout of /var/lib/monkeysphere has 16 | changed dramatically. If you did any tricky tweaking of the files in 17 | there, you probably want to check that your changes have been 18 | preserved after the upgrade. The old files can be found in 19 | /var/lib/monkeysphere/backup-from-0.23-transition. 20 | 21 | -- Daniel Kahn Gillmor Wed, 18 Feb 2009 21:29:22 -0500 22 | 23 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/changelog: -------------------------------------------------------------------------------- 1 | monkeysphere (0.35-2) unstable; urgency=low 2 | 3 | * move from experimental to unstable. 4 | 5 | -- Daniel Kahn Gillmor Fri, 25 Feb 2011 14:37:05 -0500 6 | 7 | monkeysphere (0.35-1) experimental; urgency=low 8 | 9 | * New upstream release 10 | 11 | -- Jameson Rollins Sat, 13 Nov 2010 18:25:47 -0500 12 | 13 | monkeysphere (0.34-1) experimental; urgency=low 14 | 15 | [ Jameson Rollins ] 16 | * New upstream release (Closes: #600644) 17 | 18 | [ Daniel Kahn Gillmor ] 19 | * updated build-deps and depends to be versioned on gnupg 1.4.10 or 20 | later. 21 | 22 | -- Jameson Rollins Tue, 26 Oct 2010 10:35:04 -0400 23 | 24 | monkeysphere (0.33-1) experimental; urgency=low 25 | 26 | * New upstream release (Closes: #600304, #591118) 27 | 28 | -- Jameson Rollins Fri, 15 Oct 2010 18:06:42 -0400 29 | 30 | monkeysphere (0.32-1) experimental; urgency=low 31 | 32 | * New upstream release 33 | * remove the etc/X11/Xsession.d/70monkeysphere_use-validation-agent 34 | script, since msva will now be handling that itself. 35 | * bumped Standards-Version to 3.9.1 (no changes needed) 36 | 37 | -- Jameson Rollins Wed, 06 Oct 2010 17:52:09 -0400 38 | 39 | monkeysphere (0.31-1) unstable; urgency=low 40 | 41 | * New Upstream Release 42 | * updated Xsession.d script to avoid choking when 43 | /etc/monkeysphere/monkeysphere.conf has been removed. 44 | * bumped Standards-Version to 3.9.0 (no changes needed) 45 | 46 | -- Daniel Kahn Gillmor Thu, 15 Jul 2010 19:22:11 -0400 47 | 48 | monkeysphere (0.30-1) unstable; urgency=low 49 | 50 | [ Daniel Kahn Gillmor] 51 | * New upstream release 52 | - handles lack of openssh utilities gracefully 53 | * moved openssh-client from Depends: to Recommends: (Closes: #574170) 54 | * Move to git buildpackage 55 | * Specify source format 3.0 (quilt) 56 | 57 | [ Micah Anderson ] 58 | * Remove duplicate Changelog install 59 | 60 | -- Daniel Kahn Gillmor Sat, 17 Apr 2010 20:42:11 -0400 61 | 62 | monkeysphere (0.29-1) unstable; urgency=low 63 | 64 | [ Jameson Graef Rollins ] 65 | * New upstream release 66 | 67 | [ Daniel Kahn Gillmor ] 68 | * bumped Standards-Version to 3.8.4 (no changes needed) 69 | * indicated bash dependency on version 3.2 or later (see MS #1687) 70 | * including /etc/Xsession.d/70monkeysphere_use_validation_agent so that 71 | administrators and users can choose to start up a validation agent for 72 | each X session using monkeysphere.conf 73 | 74 | -- Daniel Kahn Gillmor Sun, 14 Mar 2010 21:07:17 -0400 75 | 76 | monkeysphere (0.28-1) unstable; urgency=low 77 | 78 | * New upstream release 79 | * Separate upstream and debian changelogs 80 | 81 | -- Jameson Rollins Tue, 19 Jan 2010 13:56:17 -0500 82 | 83 | monkeysphere (0.27-1) unstable; urgency=low 84 | 85 | * New upstream release 86 | * updated debian/copyright to match the latest revision of DEP5. 87 | * updated standards version to 3.8.3 (no changes needed) 88 | * add cpio to Build-Depends (used in test suite) (Closes: #562444) 89 | 90 | -- Jameson Rollins Mon, 11 Jan 2010 20:54:21 -0500 91 | 92 | monkeysphere (0.26-1) unstable; urgency=low 93 | 94 | * New upstream release (Closes: #527765) 95 | 96 | -- Jameson Graef Rollins Sat, 01 Aug 2009 17:11:05 -0400 97 | 98 | monkeysphere (0.25-1) unstable; urgency=low 99 | 100 | * New upstream release (closes: #534008) 101 | * update Standard-Version to 3.8.2 (no changes needed) 102 | 103 | -- Jameson Graef Rollins Thu, 16 Jul 2009 22:09:19 -0400 104 | 105 | monkeysphere (0.24-1) unstable; urgency=low 106 | 107 | * New upstream release (Closes: #517779) 108 | * update/cleanup maintainer scripts 109 | * remove GnuTLS dependency 110 | * remove versioned coreutils | base64 dependency 111 | * added Build-Deps for dh_autotest 112 | * switch to Architecture: all 113 | * added cron to Recommends 114 | 115 | -- Jameson Graef Rollins Tue, 03 Mar 2009 19:38:33 -0500 116 | 117 | monkeysphere (0.23.1-1) unstable; urgency=low 118 | 119 | * New upstrem release ("brown paper bag" to adjust internal version numbers) 120 | 121 | -- Daniel Kahn Gillmor Sat, 21 Feb 2009 18:09:47 -0500 122 | 123 | monkeysphere (0.23-1) unstable; urgency=low 124 | 125 | * New upstream release: "The Golden Bezoar Release" 126 | 127 | -- Daniel Kahn Gillmor Sat, 21 Feb 2009 17:51:06 -0500 128 | 129 | monkeysphere (0.22-1) unstable; urgency=low 130 | 131 | * New upstream release 132 | * debian/control: corrected alternate dependency from procfile to 133 | procmail (which provides /usr/bin/lockfile) 134 | 135 | -- Jameson Graef Rollins Fri, 28 Nov 2008 14:23:31 -0500 136 | 137 | monkeysphere (0.21-2) unstable; urgency=low 138 | 139 | * actually rmdir /var/lib/monkeysphere-* during prerm if possible. 140 | 141 | -- Daniel Kahn Gillmor Sat, 15 Nov 2008 16:36:57 -0500 142 | 143 | monkeysphere (0.21-1) unstable; urgency=low 144 | 145 | * New upstream initial release to Debian (Closes: #505806) 146 | * Add debian prerm script, and add debhelper lines to other install 147 | scripts. 148 | 149 | -- Jameson Graef Rollins Sat, 15 Nov 2008 16:14:27 -0500 150 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/control: -------------------------------------------------------------------------------- 1 | Source: monkeysphere 2 | Section: net 3 | Priority: extra 4 | Maintainer: Jameson Rollins 5 | Uploaders: Daniel Kahn Gillmor 6 | Build-Depends: debhelper (>= 7.0.50~), 7 | cpio, 8 | socat, 9 | openssh-server, 10 | gnupg (>= 1.4.10), 11 | libcrypt-openssl-rsa-perl, 12 | libdigest-sha-perl, 13 | lockfile-progs | procmail, 14 | openssl, 15 | bash (>= 3.2) 16 | Standards-Version: 3.9.1 17 | Homepage: http://web.monkeysphere.info/ 18 | Vcs-Git: git://git.monkeysphere.info/monkeysphere 19 | Dm-Upload-Allowed: yes 20 | 21 | Package: monkeysphere 22 | Architecture: all 23 | Depends: 24 | gnupg (>= 1.4.10), 25 | libcrypt-openssl-rsa-perl, 26 | libdigest-sha-perl, 27 | lockfile-progs | procmail, 28 | adduser, 29 | ${misc:Depends} 30 | Recommends: netcat | socat, 31 | ssh-askpass, 32 | cron, 33 | openssh-client 34 | Suggests: monkeysphere-validation-agent 35 | Enhances: openssh-client, openssh-server 36 | Description: leverage the OpenPGP web of trust for SSH and TLS authentication 37 | SSH key-based authentication is tried-and-true, but it lacks a true 38 | Public Key Infrastructure for key certification, revocation and 39 | expiration. Monkeysphere is a framework that uses the OpenPGP web of 40 | trust for these PKI functions. It can be used in both directions: 41 | for users to get validated host keys, and for hosts to authenticate 42 | users. Current monkeysphere SSH tools are designed to integrate 43 | with the OpenSSH implementation of the Secure Shell protocol. 44 | . 45 | Monkeysphere can also be used by a validation agent to validate TLS 46 | connections (e.g. https). 47 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/copyright: -------------------------------------------------------------------------------- 1 | Name: Monkeysphere 2 | Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=59 3 | Source: http://web.monkeysphere.info/download 4 | Maintainer: Monkeysphere Developers 5 | 6 | Files: * 7 | Copyright: 2008,2009 Jameson Rollins , 8 | Daniel Kahn Gillmor , 9 | Jamie McClelland , 10 | Micah Anderson , 11 | Matthew Goins , 12 | Mike Castleman , 13 | Elliot Winard , 14 | Ross Glover , 15 | Greg Lyle 16 | License: GPL-3+ 17 | 18 | License: GPL-3+ 19 | This package is free software; you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation; either version 3 of the License, or 22 | (at your option) any later version. 23 | . 24 | On Debian systems, the complete text of the GNU General Public License 25 | version 3 can be found in file "/usr/share/common-licenses/GPL-3". 26 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/gbp.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | upstream-branch = master 3 | debian-branch = debian 4 | upstream-tag = monkeysphere_%(version)s 5 | debian-tag = monkeysphere_debian/%(version)s 6 | pristine-tar = False 7 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/monkeysphere.dirs: -------------------------------------------------------------------------------- 1 | var/lib/monkeysphere 2 | usr/bin 3 | usr/sbin 4 | usr/share 5 | usr/share/monkeysphere 6 | usr/share/man 7 | usr/share/man/man1 8 | usr/share/man/man7 9 | usr/share/man/man8 10 | etc/monkeysphere 11 | etc/X11 12 | etc/X11/Xsession.d 13 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/monkeysphere.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # postinst script for monkeysphere 4 | 5 | # Author: Jameson Rollins 6 | # Copyright 2008-2010 7 | 8 | set -e 9 | 10 | VARLIB="/var/lib/monkeysphere" 11 | 12 | case $1 in 13 | configure) 14 | # add a monkeysphere user if one does not already exist 15 | if ! getent passwd monkeysphere >/dev/null ; then 16 | echo "adding monkeysphere user..." 17 | adduser --quiet --system --no-create-home --group \ 18 | --home "$VARLIB" \ 19 | --shell '/bin/bash' \ 20 | --gecos 'monkeysphere authentication user,,,' \ 21 | monkeysphere 22 | fi 23 | 24 | # try all available transitions: 25 | for trans in 0.23 0.28 ; do 26 | /usr/share/monkeysphere/transitions/$trans || { \ 27 | RET=$? 28 | echo "Failed running transition script /usr/share/monkeysphere/transitions/$trans" >&2 29 | exit $RET 30 | } 31 | done 32 | 33 | 34 | # setup monkeysphere authentication 35 | monkeysphere-authentication setup 36 | ;; 37 | esac 38 | 39 | # dh_installdeb will replace this with shell code automatically 40 | # generated by other debhelper scripts. 41 | 42 | #DEBHELPER# 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/monkeysphere.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # postrm script for monkeysphere 4 | 5 | # Author: Jameson Rollins 6 | # Copyright 2008-2009 7 | 8 | set -e 9 | 10 | case $1 in 11 | purge) 12 | # delete monkeysphere user 13 | # http://wiki.debian.org/AccountHandlingInMaintainerScripts 14 | if which deluser >/dev/null 2>&1 ; then 15 | deluser --quiet --system monkeysphere > /dev/null || true 16 | else 17 | echo >&2 "not removing monkeysphere system account because deluser command was not found" 18 | fi 19 | ;; 20 | esac 21 | 22 | # dh_installdeb will replace this with shell code automatically 23 | # generated by other debhelper scripts. 24 | 25 | #DEBHELPER# 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/debian/monkeysphere.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | # prerm script for monkeysphere 4 | 5 | # the only thing we're doing here is making sure that the local 6 | # administrator is not trying to downgrade to a version below 0.23, 7 | # since there was such a major reorganization of system data during 8 | # the transition to 0.23. 9 | 10 | # Author: Daniel Kahn Gillmor 11 | # Copyright 2009 12 | 13 | set -e 14 | 15 | case "$1" in 16 | upgrade) 17 | if dpkg --compare-versions "$2" lt 0.23 ; then 18 | cat >&2 < 6 | # Jamie McClelland 7 | # Daniel Kahn Gillmor 8 | # Micah Anderson 9 | # 10 | # They are Copyright 2008-2009, and are all released under the GPL, version 3 11 | # or later. 12 | 13 | # update all keys from the key servers 14 | monkeysphere-authentication refresh-keys 15 | 16 | # update all user authorized_keys files 17 | monkeysphere-authentication update-users 18 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/etc/monkeysphere-authentication.conf: -------------------------------------------------------------------------------- 1 | # Monkeysphere authentication configuration file. 2 | 3 | # This is an sh-style shell configuration file. Variable names should 4 | # be separated from their assignments by a single '=' and no spaces. 5 | # Environment variables with the same names as these variables but 6 | # prefaced by "MONKEYSPHERE_" will take precedence over the values 7 | # specified here. 8 | 9 | # Log level. Can be SILENT, ERROR, INFO, VERBOSE, DEBUG, in 10 | # increasing order of verbosity. 11 | #LOG_LEVEL=INFO 12 | 13 | # OpenPGP keyserver 14 | #KEYSERVER=pool.sks-keyservers.net 15 | 16 | # User who controls the monkeysphere 'sphere' keyring. 17 | #MONKEYSPHERE_USER=monkeysphere 18 | 19 | # Whether or not to query keyservers by default 20 | #CHECK_KEYSERVER=true 21 | 22 | # Path to authorized_user_ids file to process to create 23 | # authorized_keys file. '%h' will be replaced by the home directory 24 | # of the user, and '%u' will be replaced by the username of the user. 25 | # For purely admin-controlled authorized_user_ids, you might put them 26 | # in /etc/monkeysphere/authorized_user_ids/%u, for instance. 27 | #AUTHORIZED_USER_IDS="%h/.monkeysphere/authorized_user_ids" 28 | 29 | # Path to a user controlled authorized_keys file to be added to the 30 | # monkeysphere-generated authorized_keys file. '%h' will be replaced 31 | # by the home directory of the user, and '%u' will by replaced by the 32 | # username of the user. Setting this variable to 'none' prevents the 33 | # inclusion of user controlled authorized_keys file. 34 | #RAW_AUTHORIZED_KEYS="%h/.ssh/authorized_keys" 35 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/etc/monkeysphere-host.conf: -------------------------------------------------------------------------------- 1 | # Monkeysphere host configuration file. 2 | 3 | # This is an sh-style shell configuration file. Variable names should 4 | # be separated from their assignments by a single '=' and no spaces. 5 | # Environment variables with the same names as these variables but 6 | # prefaced by "MONKEYSPHERE_" will take precedence over the values 7 | # specified here. 8 | 9 | # Log level. Can be SILENT, ERROR, INFO, VERBOSE, DEBUG, in 10 | # increasing order of verbosity. 11 | #LOG_LEVEL=INFO 12 | 13 | # OpenPGP keyserver 14 | #KEYSERVER=pool.sks-keyservers.net 15 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/etc/monkeysphere.conf: -------------------------------------------------------------------------------- 1 | # Monkeysphere system-wide client configuration file. 2 | 3 | # This is an sh-style shell configuration file. Variable names should 4 | # be separated from their assignments by a single '=' and no spaces. 5 | # Environment variables with the same names as these variables but 6 | # prefaced by "MONKEYSPHERE_" will take precedence over the values 7 | # specified here. 8 | 9 | # Log level. Can be SILENT, ERROR, INFO, VERBOSE, DEBUG, in 10 | # increasing order of verbosity. 11 | #LOG_LEVEL=INFO 12 | 13 | # GPG home directory. If not specified either here or in the 14 | # MONKEYSPHERE_GNUPGHOME environment variable, then the value of the 15 | # GNUPGHOME environment variable will be used. If GNUPGHOME is not 16 | # set either, then the default value is listed below. 17 | #GNUPGHOME=~/.gnupg 18 | 19 | # GPG keyserver to search for keys. 20 | #KEYSERVER=pool.sks-keyservers.net 21 | 22 | # Set whether or not to check keyservers at every monkeysphere 23 | # interaction, including all ssh connections if you use the 24 | # monkeysphere ssh-proxycommand. Leave unset for default behavior 25 | # (see KEYSERVER CHECKING in monkeysphere(1)), or set to true or false. 26 | # NOTE: setting CHECK_KEYSERVER explicitly to true will leak 27 | # information about the timing and frequency of your ssh connections 28 | # to the maintainer of the keyserver. 29 | #CHECK_KEYSERVER=true 30 | 31 | # The path to the SSH known_hosts file. 32 | #KNOWN_HOSTS=~/.ssh/known_hosts 33 | 34 | # Whether or not to hash the generated known_hosts lines. 35 | # Should be "true" or "false". 36 | #HASH_KNOWN_HOSTS=false 37 | 38 | # The path to the SSH authorized_keys file. 39 | #AUTHORIZED_KEYS=~/.ssh/authorized_keys 40 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/examples/crontab: -------------------------------------------------------------------------------- 1 | # example Monkeysphere cron job: 2 | 3 | # Hourly: update the per-user authorized_keys in /var based on 4 | # ~/.monkeysphere/authorized_user_ids 5 | 6 | 36 * * * * root /usr/sbin/monkeysphere-authentication update-users 7 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/examples/ssh_config: -------------------------------------------------------------------------------- 1 | # Monkeysphere ssh config stanza (for ~/.ssh/config or /etc/ssh_config) 2 | # This checks for host keys in the OpenPGP WoT: 3 | Host * 4 | ProxyCommand monkeysphere ssh-proxycommand %h %p 5 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/examples/sshd_config: -------------------------------------------------------------------------------- 1 | # Monkeysphere sshd config (for use in /etc/sshd_config) 2 | # This checks for user keys in the OpenPGP WoT: 3 | AuthorizedKeysFile /var/lib/monkeysphere/authorized_keys/%u 4 | 5 | # be sure to also add a scheduled job to update these keys 6 | # (see the example cronjob) 7 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/man/man1/monkeysphere.1: -------------------------------------------------------------------------------- 1 | .TH MONKEYSPHERE "1" "June 2008" "monkeysphere" "User Commands" 2 | 3 | .SH NAME 4 | 5 | monkeysphere - Monkeysphere client user interface 6 | 7 | .SH SYNOPSIS 8 | 9 | .B monkeysphere \fIsubcommand\fP [\fIargs\fP] 10 | 11 | .SH DESCRIPTION 12 | 13 | \fBMonkeysphere\fP is a framework to leverage the OpenPGP web of trust 14 | for OpenSSH and TLS key-based authentication. OpenPGP keys are 15 | tracked via GnuPG, and added to the authorized_keys and known_hosts 16 | files used by OpenSSH for connection authentication. Monkeysphere can 17 | also be used by a validation agent to validate TLS connections 18 | (e.g. https). 19 | 20 | \fBmonkeysphere\fP is the Monkeysphere client utility. 21 | 22 | .SH SUBCOMMANDS 23 | 24 | \fBmonkeysphere\fP takes various subcommands: 25 | .TP 26 | .B update\-known_hosts [HOST]... 27 | Update the known_hosts file. For each specified host, gpg will be 28 | queried for a key associated with the host URI (see HOST 29 | IDENTIFICATION in 30 | .BR monkeysphere(7)), 31 | optionally querying a keyserver. 32 | If an acceptable key is found for the host (see KEY ACCEPTABILITY in 33 | .BR monkeysphere(7)), 34 | the key is added to the user's known_hosts file. If a key is found 35 | but is unacceptable for the host, any matching keys are removed from 36 | the user's known_hosts file. If no gpg key is found for the host, 37 | nothing is done. If no hosts are specified, all hosts listed in the 38 | known_hosts file will be processed. This subcommand will exit with a 39 | status of 0 if at least one acceptable key was found for a specified 40 | host, 1 if no matching keys were found at all, and 2 if matching keys 41 | were found but none were acceptable. `k' may be used in place of 42 | `update\-known_hosts'. 43 | .TP 44 | .B update\-authorized_keys 45 | Update the authorized_keys file for the user executing the command 46 | (see MONKEYSPHERE_AUTHORIZED_KEYS in ENVIRONMENT, below). First all 47 | monkeysphere keys are cleared from the authorized_keys file. Then, 48 | for each user ID in the user's authorized_user_ids file, gpg will be 49 | queried for keys associated with that user ID, optionally querying a 50 | keyserver. If an acceptable key is found (see KEY ACCEPTABILITY in 51 | .BR monkeysphere (7)), 52 | the key is added to the user's authorized_keys file. 53 | If a key is found but is unacceptable for the user ID, any matching 54 | keys are removed from the user's authorized_keys file. If no gpg key 55 | is found for the user ID, nothing is done. This subcommand will exit 56 | with a status of 0 if at least one acceptable key was found for a user 57 | ID, 1 if no matching keys were found at all, and 2 if matching keys 58 | were found but none were acceptable. `a' may be used in place of 59 | `update\-authorized_keys'. 60 | .TP 61 | .B gen\-subkey [KEYID] 62 | Generate an authentication subkey for a private key in your GnuPG 63 | keyring. KEYID is the key ID for the primary key for which the subkey 64 | with "authentication" capability will be generated. If no key ID is 65 | specified, but only one key exists in the secret keyring, that key 66 | will be used. The length of the generated key can be specified with 67 | the `\-\-length' or `\-l' option. `g' may be used in place of 68 | `gen\-subkey'. 69 | .TP 70 | .B ssh\-proxycommand [--no-connect] HOST [PORT] 71 | An ssh ProxyCommand that can be used to trigger a monkeysphere update 72 | of the ssh known_hosts file for a host that is being connected to with 73 | ssh. This works by updating the known_hosts file for the host first, 74 | before an attempted connection to the host is made. Once the 75 | known_hosts file has been updated, a TCP connection to the host is 76 | made by exec'ing netcat(1). Regular ssh communication is then done 77 | over this netcat TCP connection (see ProxyCommand in ssh_config(5) for 78 | more info). 79 | 80 | This command is meant to be run as the ssh "ProxyCommand". This can 81 | either be done by specifying the proxy command on the command line: 82 | 83 | .B ssh \-o ProxyCommand="monkeysphere ssh\-proxycommand %h %p" ... 84 | 85 | or by adding the following line to your ~/.ssh/config script: 86 | 87 | .B ProxyCommand monkeysphere ssh\-proxycommand %h %p 88 | 89 | The script can easily be incorporated into other ProxyCommand scripts 90 | by calling it with the "\-\-no\-connect" option, i.e.: 91 | 92 | .B monkeysphere ssh\-proxycommand \-\-no\-connect "$HOST" "$PORT" 93 | 94 | This will run everything except the final exec of netcat to make the 95 | TCP connection to the host. In this way this command can be added to 96 | another proxy command that does other stuff, and then makes the 97 | connection to the host itself. 98 | 99 | KEYSERVER CHECKING: 100 | The proxy command has a fairly nuanced policy for when keyservers are 101 | queried when processing a host. If the host userID is not found in 102 | either the user's keyring or in the known_hosts file, then the 103 | keyserver is queried for the host userID. If the host userID is found 104 | in the user's keyring, then the keyserver is not checked. This 105 | assumes that the keyring is kept up-to-date, in a cronjob or the like, 106 | so that revocations are properly handled. If the host userID is not 107 | found in the user's keyring, but the host is listed in the known_hosts 108 | file, then the keyserver is not checked. This last policy might 109 | change in the future, possibly by adding a deferred check, so that 110 | hosts that go from non-monkeysphere-enabled to monkeysphere-enabled 111 | will be properly checked. 112 | 113 | Setting the CHECK_KEYSERVER variable in the config file or the 114 | MONKEYSPHERE_CHECK_KEYSERVER environment variable to either `true' or 115 | `false' will override the keyserver-checking policy defined above and 116 | either always or never check the keyserver for host key updates. 117 | 118 | .TP 119 | .B subkey\-to\-ssh\-agent [ssh\-add arguments] 120 | Push all authentication-capable subkeys in your GnuPG secret keyring 121 | into your running ssh-agent. Additional arguments are passed through 122 | to 123 | .BR ssh\-add (1). 124 | For example, to remove the authentication subkeys, pass an additional 125 | `\-d' argument. To require confirmation on each use of the key, pass 126 | `\-c'. The MONKEYSPHERE_SUBKEYS_FOR_AGENT environment can be used to 127 | specify the full fingerprints of specific keys to add to the agent 128 | (space separated), instead of adding them all. `s' may be used in 129 | place of `subkey\-to\-ssh\-agent'. 130 | .TP 131 | .B keys\-for\-userid USERID 132 | Output to stdout all acceptable keys for a given user ID. 133 | `u' may be used in place of `keys\-for\-userid'. 134 | .TP 135 | .B sshfprs\-for\-userid USERID 136 | Output the ssh fingerprints of acceptable keys for a given user ID. 137 | .TP 138 | .B version 139 | Show the monkeysphere version number. `v' may be used in place of 140 | `version'. 141 | .TP 142 | .B help 143 | Output a brief usage summary. `h' or `?' may be used in place of 144 | `help'. 145 | 146 | .SH ENVIRONMENT 147 | 148 | The following environment variables will override those specified in 149 | the monkeysphere.conf configuration file (defaults in parentheses): 150 | .TP 151 | MONKEYSPHERE_LOG_LEVEL 152 | Set the log level. Can be SILENT, ERROR, INFO, VERBOSE, DEBUG, 153 | in increasing order of verbosity. (INFO) 154 | .TP 155 | MONKEYSPHERE_GNUPGHOME, GNUPGHOME 156 | GnuPG home directory. (~/.gnupg) 157 | .TP 158 | MONKEYSPHERE_KEYSERVER 159 | OpenPGP keyserver to use. (pool.sks-keyservers.net) 160 | .TP 161 | MONKEYSPHERE_CHECK_KEYSERVER 162 | Whether or not to check keyserver when making gpg queries. (true) 163 | .TP 164 | MONKEYSPHERE_KNOWN_HOSTS 165 | Path to ssh known_hosts file. (~/.ssh/known_hosts) 166 | .TP 167 | MONKEYSPHERE_HASH_KNOWN_HOSTS 168 | Whether or not to hash to the known_hosts file entries. (false) 169 | .TP 170 | MONKEYSPHERE_AUTHORIZED_KEYS 171 | Path to ssh authorized_keys file. (~/.ssh/authorized_keys) 172 | .TP 173 | MONKEYSPHERE_PROMPT 174 | If set to `false', never prompt the user for confirmation. (true) 175 | .TP 176 | MONKEYSPHERE_STRICT_MODES 177 | If set to `false', ignore too-loose permissions on known_hosts, 178 | authorized_keys, and authorized_user_ids files. NOTE: setting this to 179 | false may expose you to abuse by other users on the system. (true) 180 | .TP 181 | MONKEYSPHERE_SUBKEYS_FOR_AGENT 182 | A space-separated list of authentication-capable subkeys to add to the 183 | ssh agent with subkey-to-ssh-agent. 184 | 185 | .SH FILES 186 | 187 | .TP 188 | ~/.monkeysphere/monkeysphere.conf 189 | User monkeysphere config file. 190 | .TP 191 | __SYSCONFDIR_PREFIX__/etc/monkeysphere/monkeysphere.conf 192 | System-wide monkeysphere config file. 193 | .TP 194 | ~/.monkeysphere/authorized_user_ids 195 | A list of OpenPGP user IDs, one per line. OpenPGP keys with an 196 | exactly-matching User ID (calculated valid by the designated identity 197 | certifiers), will have any valid authorization-capable keys or subkeys 198 | added to the given user's authorized_keys file. 199 | 200 | .SH AUTHOR 201 | 202 | Written by: 203 | Jameson Rollins , 204 | Daniel Kahn Gillmor 205 | 206 | .SH SEE ALSO 207 | 208 | .BR monkeysphere\-host (8), 209 | .BR monkeysphere\-authentication (8), 210 | .BR monkeysphere (7), 211 | .BR ssh (1), 212 | .BR ssh\-add (1), 213 | .BR gpg (1) 214 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/man/man1/openpgp2ssh.1: -------------------------------------------------------------------------------- 1 | .\" -*- nroff -*- 2 | .Dd $Mdocdate: March 1, 2009 $ 3 | .Dt OPENPGP2SSH 1 4 | .Os 5 | .Sh NAME 6 | openpgp2ssh 7 | .Nd translate OpenPGP keys to SSH keys 8 | .Sh SYNOPSIS 9 | .Nm openpgp2ssh < mykey.gpg 10 | .Pp 11 | .Nm gpg \-\-export $KEYID | openpgp2ssh $KEYID 12 | .Pp 13 | .Nm gpg \-\-export\-secret\-key $KEYID | openpgp2ssh $KEYID 14 | .Sh DESCRIPTION 15 | .Nm 16 | takes an OpenPGP-formatted primary key and associated 17 | subkeys on standard input, and spits out the requested equivalent 18 | SSH-style key on standard output. 19 | .Pp 20 | If the data on standard input contains no subkeys, you can invoke 21 | .Nm 22 | without arguments. If the data on standard input contains multiple 23 | keys (e.g. a primary key and associated subkeys), you must specify a 24 | specific OpenPGP key identifier as the first argument to indicate 25 | which key to export. The key ID is normally the 40 hex digit OpenPGP 26 | fingerprint of the key or subkey desired, but 27 | .Nm 28 | will accept as few as the last 8 digits of the fingerprint as a key 29 | ID. 30 | .Pp 31 | If the input contains an OpenPGP RSA public key, it will be converted 32 | to the OpenSSH-style single-line keystring, prefixed with the key type 33 | (`ssh\-rsa'). This format is suitable (with minor alterations) for 34 | insertion into known_hosts files and authorized_keys files. 35 | .Pp 36 | If the input contains an OpenPGP RSA secret key, it will be converted 37 | to the equivalent PEM-encoded private key. 38 | .Pp 39 | .Nm 40 | is part of the 41 | .Xr monkeysphere 7 42 | framework for providing a PKI for SSH. 43 | .Sh CAVEATS 44 | The keys produced by this process are stripped of all identifying 45 | information, including certifications, self-signatures, etc. This is 46 | intentional, since ssh attaches no inherent significance to these 47 | features. 48 | .Pp 49 | .Nm 50 | will produce output for any requested RSA key. This means, among 51 | other things, that it will happily export revoked keys, unverifiable 52 | keys, expired keys, etc. Make sure you do your own key validation 53 | before using this tool! 54 | .Sh EXAMPLES 55 | .Nm gpg \-\-export\-secret\-key $KEYID | openpgp2ssh $KEYID | ssh\-add \-c /dev/stdin 56 | .Pp 57 | This pushes the secret key into the active 58 | .Xr ssh\-agent 1 . 59 | Tools such as 60 | .Xr ssh 1 61 | which know how to talk to the 62 | .Xr ssh\-agent 1 63 | can now rely on the key. 64 | .Sh AUTHOR 65 | .Nm 66 | and this man page were written by Daniel Kahn Gillmor 67 | . 68 | .Sh BUGS 69 | .Nm 70 | only works with RSA keys. DSA keys are the only other key type 71 | available in both OpenPGP and SSH, but they are currently unsupported 72 | by this utility. 73 | .Pp 74 | .Nm 75 | only accepts raw OpenPGP packets on standard input. It does not 76 | accept ASCII-armored input. 77 | .Nm 78 | Currently only exports into formats used by the OpenSSH. 79 | It should support other key output formats, such as those used by 80 | .Xr lsh 1 81 | and 82 | .Xr putty 1 . 83 | .Pp 84 | Secret key output is currently not passphrase-protected. 85 | .Pp 86 | .Nm 87 | currently cannot handle passphrase-protected secret keys on input. 88 | .Sh SEE ALSO 89 | .Xr pem2openpgp 1 , 90 | .Xr monkeysphere 1 , 91 | .Xr monkeysphere 7 , 92 | .Xr ssh 1 , 93 | .Xr monkeysphere-authentication 8 , 94 | .Xr monkeysphere-host 8 95 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/man/man1/pem2openpgp.1: -------------------------------------------------------------------------------- 1 | .\" -*- nroff -*- 2 | .Dd $Mdocdate: March 1, 2009 $ 3 | .Dt PEM2OPENPGP 1 4 | .Os 5 | .Sh NAME 6 | pem2openpgp 7 | .Nd translate PEM-encoded RSA keys to OpenPGP certificates 8 | .Sh SYNOPSIS 9 | .Nm pem2openpgp "$USERID" < mykey.pem | gpg \-\-import 10 | .Pp 11 | .Nm PEM2OPENPGP_EXPIRATION=$((86400 * $DAYS)) PEM2OPENPGP_USAGE_FLAGS=authenticate,certify pem2openpgp "$USERID" . 71 | .Sh BUGS 72 | Only handles RSA keys at the moment. It might be nice to handle DSA 73 | keys as well. 74 | .Pp 75 | Currently only creates certificates with a single User ID. Should be 76 | able to create certificates with multiple User IDs. 77 | .Pp 78 | Currently only accepts unencrypted RSA keys. It should be able to 79 | deal with passphrase-locked key material. 80 | .Pp 81 | Currently outputs OpenPGP certificates with cleartext secret key 82 | material. It would be good to be able to lock the output with a 83 | passphrase. 84 | .Pp 85 | If you find other bugs, please report them at 86 | https://labs.riseup.net/code/projects/show/monkeysphere 87 | .Sh SEE ALSO 88 | .Xr openpgp2ssh 1, 89 | .Xr monkeysphere 1 , 90 | .Xr monkeysphere 7 , 91 | .Xr ssh 1 , 92 | .Xr monkeysphere\-host 8 , 93 | .Xr monkeysphere\-authentication 8 94 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/man/man7/monkeysphere.7: -------------------------------------------------------------------------------- 1 | .TH MONKEYSPHERE "7" "March 2010" "monkeysphere" "System Frameworks" 2 | 3 | .SH NAME 4 | 5 | monkeysphere - ssh and TLS authentication framework using OpenPGP Web of Trust 6 | 7 | .SH DESCRIPTION 8 | 9 | \fBMonkeysphere\fP is a framework to leverage the OpenPGP web of trust 10 | for OpenSSH and TLS key-based authentication. OpenPGP keys are 11 | tracked via GnuPG, and added to the authorized_keys and known_hosts 12 | files used by OpenSSH for connection authentication. Monkeysphere can 13 | also be used by a validation agent to validate TLS connections 14 | (e.g. https). 15 | 16 | .SH IDENTITY CERTIFIERS 17 | 18 | Each host that uses the \fBMonkeysphere\fP to authenticate its remote 19 | users needs some way to determine that those users are who they claim 20 | to be. SSH permits key-based authentication, but we want instead to 21 | bind authenticators to human-comprehensible user identities. This 22 | switch from raw keys to User IDs makes it possible for administrators 23 | to see intuitively who has access to an account, and it also enables 24 | end users to transition keys (and revoke compromised ones) 25 | automatically across all \fBMonkeysphere\fP-enabled hosts. The User 26 | IDs and certifications that the \fBMonkeysphere\fP relies on are found 27 | in the OpenPGP Web of Trust. 28 | 29 | However, in order to establish this binding, each host must know whose 30 | cerifications to trust. Someone who a host trusts to certify User 31 | Identities is called an Identity Certifier. A host must have at least 32 | one Identity Certifier in order to bind User IDs to keys. Commonly, 33 | every ID Certifier would be trusted by the host to fully identify any 34 | User ID, but more nuanced approaches are possible as well. For 35 | example, a given host could specify a dozen ID certifiers, but assign 36 | them all "marginal" trust. Then any given User ID would need to be 37 | certified in the OpenPGP Web of Trust by at least three of those 38 | certifiers. 39 | 40 | It is also possible to limit the scope of trust for a given ID 41 | Certifier to a particular domain. That is, a host can be configured 42 | to fully (or marginally) trust a particular ID Certifier only when 43 | they certify identities within, say, example.org (based on the e-mail 44 | address in the User ID). 45 | 46 | .SH KEY ACCEPTABILITY 47 | 48 | The monkeysphere commands work from a set of user IDs to determine 49 | acceptable keys for ssh and TLS authentication. OpenPGP keys are 50 | considered acceptable if the following criteria are met: 51 | .TP 52 | .B capability 53 | The key must have the `authentication' (`a') usage flag set. 54 | .TP 55 | .B validity 56 | The key itself must be valid, i.e. it must be well-formed, not 57 | expired, and not revoked. 58 | .TP 59 | .B certification 60 | The relevant user ID must be signed by a trusted identity certifier. 61 | 62 | .SH HOST IDENTIFICATION 63 | 64 | The OpenPGP keys for hosts have associated `service names` (OpenPGP 65 | user IDs) that are based on URI specifications for the service. Some 66 | examples: 67 | .TP 68 | .B ssh: 69 | ssh://host.example.com[:port] 70 | .TP 71 | .B https: 72 | https://host.example.com[:port] 73 | 74 | .SH AUTHOR 75 | 76 | Written by: 77 | Jameson Rollins , 78 | Daniel Kahn Gillmor 79 | 80 | .SH SEE ALSO 81 | 82 | .BR monkeysphere (1), 83 | .BR monkeysphere\-host (8), 84 | .BR monkeysphere\-authentication (8), 85 | .BR openpgp2ssh (1), 86 | .BR pem2openpgp (1), 87 | .BR gpg (1), 88 | .BR http://tools.ietf.org/html/rfc4880, 89 | .BR ssh (1), 90 | .BR http://tools.ietf.org/wg/secsh/draft\-ietf\-secsh\-scp\-sftp\-ssh\-uri/ 91 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/man/man8/monkeysphere-authentication.8: -------------------------------------------------------------------------------- 1 | .TH MONKEYSPHERE-AUTHENTICATION "8" "July 3, 2010" "monkeysphere" "System Commands" 2 | 3 | .SH NAME 4 | 5 | monkeysphere\-authentication - Monkeysphere authentication admin tool. 6 | 7 | .SH SYNOPSIS 8 | 9 | .B monkeysphere\-authentication \fIsubcommand\fP [\fIargs\fP] 10 | 11 | .SH DESCRIPTION 12 | 13 | \fBMonkeysphere\fP is a framework to leverage the OpenPGP Web of Trust 14 | (WoT) for key-based authentication. OpenPGP keys are tracked via 15 | GnuPG, and added to the authorized_keys files used by OpenSSH for 16 | connection authentication. 17 | 18 | \fBmonkeysphere\-authentication\fP is a Monkeysphere server admin 19 | utility for configuring and managing SSH user authentication through 20 | the WoT. 21 | 22 | .SH SUBCOMMANDS 23 | 24 | \fBmonkeysphere\-authentication\fP takes various subcommands: 25 | .TP 26 | .B update\-users [USER]... 27 | Rebuild the monkeysphere-controlled authorized_keys files. For each 28 | specified account, the user ID's listed in the account's 29 | authorized_user_ids file are processed. For each user ID, gpg will be 30 | queried for keys associated with that user ID, optionally querying a 31 | keyserver. If an acceptable key is found (see KEY ACCEPTABILITY in 32 | monkeysphere(7)), the key is added to the account's 33 | monkeysphere-controlled authorized_keys file. If the 34 | RAW_AUTHORIZED_KEYS variable is set, then a separate authorized_keys 35 | file (usually ~USER/.ssh/authorized_keys) is appended to the 36 | monkeysphere-controlled authorized_keys file. If no accounts are 37 | specified, then all accounts on the system are processed. `u' may be 38 | used in place of `update\-users'. 39 | .TP 40 | .B keys\-for\-user USER 41 | Output to stdout authorized_keys lines for USER. This command behaves 42 | exactly like update\-users (above), except that the resulting 43 | authorized_keys lines are output to stdout, instead of being written 44 | to the monkeysphere-controlled authorized_keys file. 45 | .TP 46 | .B refresh\-keys 47 | Refresh all keys in the monkeysphere-authentication keyring. If no 48 | accounts are specified, then all accounts on the system are processed. 49 | `r' may be used in place of `refresh\-keys'. 50 | .TP 51 | .B add\-id\-certifier KEYID|FILE 52 | Instruct system to trust user identity certifications made by KEYID. 53 | The key ID will be loaded from the keyserver. A file may be loaded 54 | instead of pulling the key from the keyserver by specifying the path 55 | to the file as the argument, or by specifying `\-' to load from stdin. 56 | Using the `\-n' or `\-\-domain' option allows you to indicate that you 57 | only trust the given KEYID to make identifications within a specific 58 | domain (e.g. "trust KEYID to certify user identities within the 59 | @example.org domain"). A certifier trust level can be specified with 60 | the `\-t' or `\-\-trust' option (possible values are `marginal' and 61 | `full' (default is `full')). A certifier trust depth can be specified 62 | with the `\-d' or `\-\-depth' option (default is 1). `c+' may be used in 63 | place of `add\-id\-certifier'. 64 | .TP 65 | .B remove\-id\-certifier KEYID 66 | Instruct system to ignore user identity certifications made by KEYID. 67 | `c\-' may be used in place of `remove\-id\-certifier'. 68 | .TP 69 | .B list\-id\-certifiers 70 | List key IDs trusted by the system to certify user identities. `c' 71 | may be used in place of `list\-id\-certifiers'. 72 | .TP 73 | .B version 74 | Show the monkeysphere version number. `v' may be used in place of 75 | `version'. 76 | .TP 77 | .B help 78 | Output a brief usage summary. `h' or `?' may be used in place of 79 | `help'. 80 | 81 | 82 | Other commands: 83 | .TP 84 | .B setup 85 | Setup the server in preparation for Monkeysphere user authentication. 86 | This command is idempotent and run automatically by the other 87 | commands, and should therefore not usually need to be run manually. 88 | `s' may be used in place of `setup'. 89 | .TP 90 | .B diagnostics 91 | Review the state of the server with respect to authentication. `d' 92 | may be used in place of `diagnostics'. 93 | .TP 94 | .B gpg\-cmd 95 | Execute a gpg command, as the monkeysphere user, on the monkeysphere 96 | authentication `sphere' keyring. This takes a single argument 97 | (i.e. multiple gpg arguments need to be quoted all together). Use 98 | this command with caution, as modifying the authentication sphere 99 | keyring can affect ssh user authentication. 100 | 101 | .SH SETUP USER AUTHENTICATION 102 | 103 | If the server will handle user authentication through 104 | monkeysphere-generated authorized_keys files, the server must be told 105 | which keys will act as identity certifiers. This is done with the 106 | \fBadd\-id\-certifier\fP command: 107 | 108 | # monkeysphere\-authentication add\-id\-certifier KEYID 109 | 110 | where KEYID is the key ID of the server admin, or whoever's 111 | certifications should be acceptable to the system for the purposes of 112 | authenticating remote users. You can run this command multiple times 113 | to indicate that multiple certifiers are trusted. You may also 114 | specify a filename instead of a key ID, as long as the file contains a 115 | single OpenPGP public key. Certifiers can be removed with the 116 | \fBremove\-id\-certifier\fP command, and listed with the 117 | \fBlist\-id\-certifiers\fP command. 118 | 119 | A remote user will be granted access to a local account based on the 120 | appropriately-signed and valid keys associated with user IDs listed in 121 | that account's authorized_user_ids file. By default, the 122 | authorized_user_ids file for an account is 123 | ~/.monkeysphere/authorized_user_ids. This can be changed in the 124 | monkeysphere\-authentication.conf file. 125 | 126 | The \fBupdate\-users\fP command is used to generate authorized_keys 127 | files for a local account based on the user IDs listed in the 128 | account's authorized_user_ids file: 129 | 130 | # monkeysphere\-authentication update\-users USER 131 | 132 | Not specifying USER will cause all accounts on the system to updated. 133 | The ssh server can use these monkeysphere-generated authorized_keys 134 | files to grant access to user accounts for remote users. In order for 135 | sshd to look at the monkeysphere-generated authorized_keys file for 136 | user authentication, the AuthorizedKeysFile parameter must be set in 137 | the sshd_config to point to the monkeysphere\-generated 138 | authorized_keys files: 139 | 140 | AuthorizedKeysFile __SYSDATADIR_PREFIX__/monkeysphere/authorized_keys/%u 141 | 142 | It is recommended to add "monkeysphere\-authentication update\-users" 143 | to a system crontab, so that user keys are kept up-to-date, and key 144 | revocations and expirations can be processed in a timely manner. 145 | 146 | .SH ENVIRONMENT 147 | 148 | The following environment variables will override those specified in 149 | the config file (defaults in parentheses): 150 | .TP 151 | MONKEYSPHERE_MONKEYSPHERE_USER 152 | User to control authentication keychain. (monkeysphere) 153 | .TP 154 | MONKEYSPHERE_LOG_LEVEL 155 | Set the log level. Can be SILENT, ERROR, INFO, VERBOSE, DEBUG, in 156 | increasing order of verbosity. (INFO) 157 | .TP 158 | MONKEYSPHERE_KEYSERVER 159 | OpenPGP keyserver to use. (pool.sks\-keyservers.net) 160 | .TP 161 | MONKEYSPHERE_CHECK_KEYSERVER 162 | Whether or not to check the keyserver when making gpg queries. (true) 163 | .TP 164 | MONKEYSPHERE_AUTHORIZED_USER_IDS 165 | Path to user's authorized_user_ids file. %h gets replaced with the 166 | user's homedir, %u with the username. 167 | (%h/.monkeysphere/authorized_user_ids) 168 | .TP 169 | MONKEYSPHERE_RAW_AUTHORIZED_KEYS 170 | Path to regular ssh-style authorized_keys file to append to 171 | monkeysphere-generated authorized_keys. `none' means not to add any 172 | raw authorized_keys file. %h gets replaced with the user's homedir, 173 | %u with the username. (%h/.ssh/authorized_keys) 174 | .TP 175 | MONKEYSPHERE_PROMPT 176 | If set to `false', never prompt the user for confirmation. (true) 177 | .TP 178 | MONKEYSPHERE_STRICT_MODES 179 | If set to `false', ignore too-loose permissions on known_hosts, 180 | authorized_keys, and authorized_user_ids files. NOTE: setting this to 181 | false may expose users to abuse by other users on the system. (true) 182 | 183 | .SH FILES 184 | 185 | .TP 186 | __SYSCONFDIR_PREFIX__/etc/monkeysphere/monkeysphere\-authentication.conf 187 | System monkeysphere-authentication config file. 188 | .TP 189 | __SYSCONFDIR_PREFIX__/etc/monkeysphere/monkeysphere\-authentication\-x509\-anchors.crt or\p \ 190 | __SYSCONFDIR_PREFIX__/etc/monkeysphere/monkeysphere\-x509\-anchors.crt 191 | If monkeysphere-authentication is configured to query an hkps 192 | keyserver, it will use X.509 Certificate Authority certificates in 193 | this file to validate any X.509 certificates used by the keyserver. 194 | If the monkeysphere-authentication-x509 file is present, the 195 | monkeysphere-x509 file will be ignored. 196 | .TP 197 | __SYSDATADIR_PREFIX__/monkeysphere/authorized_keys/USER 198 | Monkeysphere-controlled user authorized_keys files. 199 | .TP 200 | ~/.monkeysphere/authorized_user_ids 201 | A list of OpenPGP user IDs, one per line. OpenPGP keys with an 202 | exactly-matching User ID (calculated valid by the designated identity 203 | certifiers), will have any valid authorization-capable keys or subkeys 204 | added to the given user's authorized_keys file. Any line with initial 205 | whitespace will be interpreted as ssh authorized_keys options 206 | applicable to the preceding User ID. 207 | 208 | .SH AUTHOR 209 | 210 | This man page was written by: 211 | Jameson Rollins , 212 | Daniel Kahn Gillmor , 213 | Matthew Goins 214 | 215 | .SH SEE ALSO 216 | 217 | .BR monkeysphere (1), 218 | .BR monkeysphere\-host (8), 219 | .BR monkeysphere (7), 220 | .BR gpg (1), 221 | .BR ssh (1), 222 | .BR sshd (8), 223 | .BR sshd_config (5) 224 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/packaging/macports/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | # $Id$ 3 | 4 | PortSystem 1.0 5 | name monkeysphere 6 | version 0.26 7 | categories net security 8 | maintainers nomaintainer 9 | description use the OpenPGP web of trust to verify ssh connections 10 | long_description SSH key-based authentication is tried-and-true, \ 11 | but it lacks a true Public Key Infrastructure for \ 12 | key certification, revocation and expiration. \ 13 | Monkeysphere is a framework that uses the OpenPGP \ 14 | web of trust for these PKI functions. It can be \ 15 | used in both directions: for users to get \ 16 | validated host keys, and for hosts to authenticate \ 17 | users. 18 | homepage http://web.monkeysphere.info/ 19 | platforms darwin 20 | 21 | depends_run bin:ssh:openssh \ 22 | port:gnupg \ 23 | port:p5-crypt-openssl-rsa \ 24 | port:p5-digest-sha \ 25 | port:procmail 26 | 27 | master_sites http://archive.monkeysphere.info/debian/pool/monkeysphere/m/monkeysphere/ 28 | distname ${name}_${version} 29 | extract.suffix .orig.tar.gz 30 | worksrcdir ${name}-${version} 31 | checksums md5 f0e5fe66a9affd951e601ea5d6188972 32 | 33 | use_configure no 34 | 35 | post-build { 36 | # update paths to SYS*DIRs 37 | exec sed -i .tmp -e "s|/etc/monkeysphere|${prefix}/etc/monkeysphere|g" \ 38 | ${worksrcpath}/src/share/defaultenv \ 39 | ${worksrcpath}/src/transitions/0.23 \ 40 | ${worksrcpath}/man/man1/monkeysphere.1 \ 41 | ${worksrcpath}/man/man8/monkeysphere-authentication.8 \ 42 | ${worksrcpath}/man/man8/monkeysphere-host.8 \ 43 | ${worksrcpath}/etc/monkeysphere-authentication.conf 44 | exec sed -i .tmp -e "s|/var/lib/monkeysphere|${prefix}/var/db/monkeysphere|g" \ 45 | ${worksrcpath}/src/transitions/0.23 \ 46 | ${worksrcpath}/man/man1/monkeysphere.1 \ 47 | ${worksrcpath}/man/man8/monkeysphere-authentication.8 \ 48 | ${worksrcpath}/man/man8/monkeysphere-host.8 \ 49 | ${worksrcpath}/src/monkeysphere-host \ 50 | ${worksrcpath}/src/monkeysphere-authentication \ 51 | ${worksrcpath}/doc/getting-started-admin.mdwn 52 | exec sed -i .tmp -e "s|/usr/share/monkeysphere|${prefix}/share/monkeysphere|g" \ 53 | ${worksrcpath}/src/monkeysphere-host \ 54 | ${worksrcpath}/src/monkeysphere-authentication \ 55 | ${worksrcpath}/src/monkeysphere 56 | 57 | # fix perl shebang line to point to macports perl install 58 | exec sed -i .tmp -e "s|^#!/usr/bin/perl -T$|#!/opt/local/bin/perl -T|" \ 59 | ${worksrcpath}/src/share/keytrans \ 60 | ${worksrcpath}/src/share/checkperms 61 | 62 | # remove leftover sed cruft 63 | exec find ${worksrcpath} -name *.tmp -delete 64 | } 65 | 66 | destroot.destdir DESTDIR=${destroot}${prefix} 67 | destroot.args PREFIX= 68 | 69 | # variant to use the port version of bash, which may be much newer 70 | # than the one provided by the system 71 | variant port-bash description {use port version of Bash} { 72 | depends_run-append port:bash 73 | } 74 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/packaging/slackware/README: -------------------------------------------------------------------------------- 1 | Monkeysphere on Slackware 2 | ========================= 3 | 4 | Silvio Rhatto has written a SlackBuild script for the monkeysphere. 5 | 6 | You can find the SlackBuild here: 7 | 8 | http://slack.sarava.org/slackbuilds/net/misc/monkeysphere/ 9 | 10 | This SlackBuild script is generated from a .mkbuild script, published 11 | separately: 12 | 13 | http://slack.sarava.org/mkbuilds/net/misc/monkeysphere/ 14 | 15 | You can read more about the mkbuild system here: 16 | 17 | http://simplepkg.sarava.org 18 | 19 | Thanks, rhatto! 20 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/monkeysphere: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # monkeysphere: Monkeysphere client tool 4 | # 5 | # The monkeysphere scripts are written by: 6 | # Jameson Rollins 7 | # Jamie McClelland 8 | # Daniel Kahn Gillmor 9 | # Micah Anderson 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, version 3 12 | # or later. 13 | 14 | ######################################################################## 15 | set -e 16 | 17 | PGRM=$(basename $0) 18 | 19 | SYSSHAREDIR=${MONKEYSPHERE_SYSSHAREDIR:-"__SYSSHAREDIR_PREFIX__/share/monkeysphere"} 20 | export SYSSHAREDIR 21 | . "${SYSSHAREDIR}/defaultenv" 22 | . "${SYSSHAREDIR}/common" 23 | 24 | # sharedir for host functions 25 | MSHAREDIR="${SYSSHAREDIR}/m" 26 | 27 | # UTC date in ISO 8601 format if needed 28 | DATE=$(date -u '+%FT%T') 29 | 30 | # unset some environment variables that could screw things up 31 | unset GREP_OPTIONS 32 | 33 | # set the file creation mask to be only owner rw 34 | umask 077 35 | 36 | ######################################################################## 37 | # FUNCTIONS 38 | ######################################################################## 39 | 40 | usage() { 41 | cat <&2 42 | usage: $PGRM [options] [args] 43 | Monkeysphere client tool. 44 | 45 | subcommands: 46 | update-known_hosts (k) [HOST]... update known_hosts file 47 | update-authorized_keys (a) update authorized_keys file 48 | ssh-proxycommand HOST [PORT] monkeysphere ssh ProxyCommand 49 | --no-connect do not make TCP connection to host 50 | subkey-to-ssh-agent (s) store authentication subkey in ssh-agent 51 | 52 | keys-for-userid (u) USERID output valid ssh keys for given user id 53 | sshfprs-for-userid USERID output ssh fingerprints for given user id 54 | gen-subkey (g) [KEYID] generate an authentication subkey 55 | --length (-l) BITS key length in bits (2048) 56 | 57 | version (v) show version number 58 | help (h,?) this help 59 | 60 | EOF 61 | } 62 | 63 | # user gpg command to define common options 64 | gpg_user() { 65 | LC_ALL=C gpg --fixed-list-mode --no-greeting --quiet --no-tty "$@" 66 | } 67 | 68 | # output the ssh fingerprint of a gpg key 69 | gpg_ssh_fingerprint() { 70 | keyid="$1" 71 | gpg_user --export "$keyid" --no-armor | "$SYSSHAREDIR/keytrans" openpgp2sshfpr "$keyid" 72 | } 73 | 74 | # take a secret key ID and check that only zero or one ID is provided, 75 | # and that it corresponds to only a single secret key ID 76 | check_gpg_sec_key_id() { 77 | local gpgSecOut 78 | 79 | case "$#" in 80 | 0) 81 | gpgSecOut=$(gpg_user --list-secret-keys --with-colons 2>/dev/null | egrep '^sec:') 82 | ;; 83 | 1) 84 | gpgSecOut=$(gpg_user --list-secret-keys --with-colons "$1" | egrep '^sec:') || failure 85 | ;; 86 | *) 87 | failure "You must specify only a single primary key ID." 88 | ;; 89 | esac 90 | 91 | # check that only a single secret key was found 92 | case $(echo "$gpgSecOut" | grep -c '^sec:') in 93 | 0) 94 | failure "No secret keys found. Create an OpenPGP key with the following command: 95 | gpg --gen-key" 96 | ;; 97 | 1) 98 | echo "$gpgSecOut" | cut -d: -f5 99 | ;; 100 | *) 101 | local seckeys=$(echo "$gpgSecOut" | cut -d: -f5) 102 | failure "Multiple primary secret keys found: 103 | $seckeys 104 | Please specify which primary key to use." 105 | ;; 106 | esac 107 | } 108 | 109 | # check that a valid authentication subkey does not already exist 110 | check_gpg_authentication_subkey() { 111 | local keyID 112 | local IFS 113 | local line 114 | local type 115 | local validity 116 | local usage 117 | 118 | keyID="$1" 119 | 120 | # check that a valid authentication key does not already exist 121 | IFS=$'\n' 122 | for line in $(gpg_user --list-keys --with-colons "$keyID") ; do 123 | type=$(echo "$line" | cut -d: -f1) 124 | validity=$(echo "$line" | cut -d: -f2) 125 | usage=$(echo "$line" | cut -d: -f12) 126 | 127 | # look at keys only 128 | if [ "$type" != 'pub' -a "$type" != 'sub' ] ; then 129 | continue 130 | fi 131 | # check for authentication capability 132 | if ! check_capability "$usage" 'a' ; then 133 | continue 134 | fi 135 | # if authentication key is valid, prompt to continue 136 | if [ "$validity" = 'u' ] ; then 137 | echo "A valid authentication key already exists for primary key '$keyID'." 1>&2 138 | if [ "$PROMPT" != "false" ] ; then 139 | printf "Are you sure you would like to generate another one? (y/N) " >&2 140 | read OK; OK=${OK:N} 141 | if [ "${OK/y/Y}" != 'Y' ] ; then 142 | failure "aborting." 143 | fi 144 | break 145 | else 146 | failure "aborting." 147 | fi 148 | fi 149 | done 150 | } 151 | 152 | ######################################################################## 153 | # MAIN 154 | ######################################################################## 155 | 156 | # set unset default variables 157 | GNUPGHOME=${GNUPGHOME:="${HOME}/.gnupg"} 158 | KNOWN_HOSTS="${HOME}/.ssh/known_hosts" 159 | HASH_KNOWN_HOSTS="false" 160 | AUTHORIZED_KEYS="${HOME}/.ssh/authorized_keys" 161 | 162 | # unset the check keyserver variable, since that needs to have 163 | # different defaults for the different functions 164 | unset CHECK_KEYSERVER 165 | 166 | # load global config 167 | [ -r "${SYSCONFIGDIR}/monkeysphere.conf" ] \ 168 | && . "${SYSCONFIGDIR}/monkeysphere.conf" 169 | 170 | # set monkeysphere home directory 171 | MONKEYSPHERE_HOME=${MONKEYSPHERE_HOME:="${HOME}/.monkeysphere"} 172 | mkdir -p -m 0700 "$MONKEYSPHERE_HOME" 173 | 174 | # load local config 175 | [ -e ${MONKEYSPHERE_CONFIG:="${MONKEYSPHERE_HOME}/monkeysphere.conf"} ] \ 176 | && . "$MONKEYSPHERE_CONFIG" 177 | 178 | # set empty config variables with ones from the environment 179 | GNUPGHOME=${MONKEYSPHERE_GNUPGHOME:=$GNUPGHOME} 180 | LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=$LOG_LEVEL} 181 | KEYSERVER=${MONKEYSPHERE_KEYSERVER:=$KEYSERVER} 182 | # if keyserver not specified in env or conf, then look in gpg.conf 183 | if [ -z "$KEYSERVER" ] ; then 184 | if [ -f "${GNUPGHOME}/gpg.conf" ] ; then 185 | KEYSERVER=$(grep -e "^[[:space:]]*keyserver " "${GNUPGHOME}/gpg.conf" | tail -1 | awk '{ print $2 }') 186 | fi 187 | fi 188 | PROMPT=${MONKEYSPHERE_PROMPT:=$PROMPT} 189 | KNOWN_HOSTS=${MONKEYSPHERE_KNOWN_HOSTS:=$KNOWN_HOSTS} 190 | HASH_KNOWN_HOSTS=${MONKEYSPHERE_HASH_KNOWN_HOSTS:=$HASH_KNOWN_HOSTS} 191 | AUTHORIZED_KEYS=${MONKEYSPHERE_AUTHORIZED_KEYS:=$AUTHORIZED_KEYS} 192 | STRICT_MODES=${MONKEYSPHERE_STRICT_MODES:=$STRICT_MODES} 193 | 194 | # other variables not in config file 195 | AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:="${MONKEYSPHERE_HOME}/authorized_user_ids"} 196 | REQUIRED_HOST_KEY_CAPABILITY=${MONKEYSPHERE_REQUIRED_HOST_KEY_CAPABILITY:="a"} 197 | REQUIRED_USER_KEY_CAPABILITY=${MONKEYSPHERE_REQUIRED_USER_KEY_CAPABILITY:="a"} 198 | # note that only using '=' instead of ':=' tests only if the variable 199 | # in unset, not if it's "null" 200 | LOG_PREFIX=${MONKEYSPHERE_LOG_PREFIX='ms: '} 201 | 202 | # export GNUPGHOME and make sure gpg home exists with proper 203 | # permissions 204 | export GNUPGHOME 205 | mkdir -p -m 0700 "$GNUPGHOME" 206 | export LOG_LEVEL 207 | export LOG_PREFIX 208 | 209 | if [ "$#" -eq 0 ] ; then 210 | usage 211 | failure "Please supply a subcommand." 212 | fi 213 | 214 | # get subcommand 215 | COMMAND="$1" 216 | shift 217 | 218 | case $COMMAND in 219 | 'update-known_hosts'|'update-known-hosts'|'k') 220 | # whether or not to check keyservers 221 | CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=${CHECK_KEYSERVER:="true"}} 222 | 223 | source "${MSHAREDIR}/update_known_hosts" 224 | 225 | # if hosts are specified on the command line, process just 226 | # those hosts 227 | if [ "$1" ] ; then 228 | update_known_hosts "$@" 229 | 230 | # otherwise, if no hosts are specified, process every host 231 | # in the user's known_hosts file 232 | else 233 | process_known_hosts 234 | fi 235 | ;; 236 | 237 | 'update-authorized_keys'|'update-authorized-keys'|'a') 238 | # whether or not to check keyservers 239 | CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=${CHECK_KEYSERVER:="true"}} 240 | source "${MSHAREDIR}/update_authorized_keys" 241 | update_authorized_keys 242 | ;; 243 | 244 | 'import-subkey'|'import'|'i') 245 | source "${MSHAREDIR}/import_subkey" 246 | import_subkey "$@" 247 | ;; 248 | 249 | 'gen-subkey'|'g') 250 | source "${MSHAREDIR}/gen_subkey" 251 | gen_subkey "$@" 252 | ;; 253 | 254 | 'ssh-proxycommand'|'p') 255 | source "${MSHAREDIR}/ssh_proxycommand" 256 | ssh_proxycommand "$@" 257 | ;; 258 | 259 | 'subkey-to-ssh-agent'|'s') 260 | source "${MSHAREDIR}/subkey_to_ssh_agent" 261 | subkey_to_ssh_agent "$@" 262 | ;; 263 | 264 | 'sshfpr') 265 | echo "Warning: 'sshfpr' is deprecated. Please use 'sshfprs-for-userid' instead." >&2 266 | gpg_ssh_fingerprint "$@" 267 | ;; 268 | 269 | 'keys-for-userid'|'u') 270 | CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=${CHECK_KEYSERVER:="true"}} 271 | source "${MSHAREDIR}/keys_for_userid" 272 | keys_for_userid "$@" 273 | ;; 274 | 275 | 'sshfprs-for-userid') 276 | CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=${CHECK_KEYSERVER:="true"}} 277 | source "${MSHAREDIR}/keys_for_userid" 278 | keys_for_userid "$@" | "$SYSSHAREDIR/keytrans" sshfpr 279 | ;; 280 | 281 | 'keys-from-userid') 282 | echo "Warning: 'keys-from-userid' is deprecated. Please use 'keys-for-userid' instead." >&2 283 | CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=${CHECK_KEYSERVER:="true"}} 284 | source "${MSHAREDIR}/keys_for_userid" 285 | keys_for_userid "$@" 286 | ;; 287 | 288 | 'version'|'--version'|'v') 289 | version 290 | ;; 291 | 292 | 'help'|'--help'|'-h'|'h'|'?') 293 | usage 294 | ;; 295 | 296 | *) 297 | failure "Unknown command: '$COMMAND' 298 | Try '$PGRM help' for usage." 299 | ;; 300 | esac 301 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/monkeysphere-authentication: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # monkeysphere-authentication: Monkeysphere authentication admin tool 4 | # 5 | # The monkeysphere scripts are written by: 6 | # Jameson Rollins 7 | # Jamie McClelland 8 | # Daniel Kahn Gillmor 9 | # Micah Anderson 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | ######################################################################## 15 | set -e 16 | 17 | # set the pipefail option so pipelines fail on first command failure 18 | set -o pipefail 19 | 20 | PGRM=$(basename $0) 21 | 22 | SYSSHAREDIR=${MONKEYSPHERE_SYSSHAREDIR:-"__SYSSHAREDIR_PREFIX__/share/monkeysphere"} 23 | export SYSSHAREDIR 24 | . "${SYSSHAREDIR}/defaultenv" 25 | . "${SYSSHAREDIR}/common" 26 | 27 | # sharedir for authentication functions 28 | MASHAREDIR="${SYSSHAREDIR}/ma" 29 | 30 | # datadir for authentication functions 31 | MADATADIR="${SYSDATADIR}/authentication" 32 | 33 | # temp directory to enable atomic moves of authorized_keys files 34 | MATMPDIR="${MADATADIR}/tmp" 35 | export MATMPDIR 36 | 37 | # UTC date in ISO 8601 format if needed 38 | DATE=$(date -u '+%FT%T') 39 | 40 | # unset some environment variables that could screw things up 41 | unset GREP_OPTIONS 42 | 43 | ######################################################################## 44 | # FUNCTIONS 45 | ######################################################################## 46 | 47 | usage() { 48 | cat <&2 49 | usage: $PGRM [options] [args] 50 | Monkeysphere authentication admin tool. 51 | 52 | subcommands: 53 | update-users (u) [USER]... update user authorized_keys files 54 | keys-for-user (k) USER output user authorized_keys lines to stdout 55 | refresh-keys (r) refresh keys in keyring 56 | 57 | add-id-certifier (c+) KEYID|FILE import and tsign a certification key 58 | [--domain (-n) DOMAIN] limit ID certifications to DOMAIN 59 | [--trust (-t) TRUST] trust level of certifier (default: full) 60 | [--depth (-d) DEPTH] trust depth for certifier (default: 1) 61 | remove-id-certifier (c-) KEYID remove a certification key 62 | list-id-certifiers (c) list certification keys 63 | 64 | version (v) show version number 65 | help (h,?) this help 66 | 67 | See ${PGRM}(8) for more info. 68 | EOF 69 | } 70 | 71 | # function to interact with the gpg core keyring 72 | gpg_core() { 73 | GNUPGHOME="$GNUPGHOME_CORE" 74 | export GNUPGHOME 75 | 76 | gpg --fixed-list-mode --no-greeting --quiet --no-tty "$@" 77 | } 78 | 79 | # function to interact with the gpg sphere keyring 80 | gpg_sphere() { 81 | GNUPGHOME="$GNUPGHOME_SPHERE" 82 | export GNUPGHOME 83 | 84 | su_monkeysphere_user "gpg --fixed-list-mode --no-greeting --quiet --no-tty $@" 85 | } 86 | 87 | # output to stdout the core fingerprint from the gpg core secret 88 | # keyring 89 | core_fingerprint() { 90 | log debug "determining core key fingerprint..." 91 | gpg_core --list-secret-key --with-colons \ 92 | --with-fingerprint \ 93 | | grep ^fpr: | cut -d: -f10 94 | } 95 | 96 | # export signatures from core to sphere 97 | gpg_core_sphere_sig_transfer() { 98 | log debug "exporting core local sigs to sphere..." 99 | gpg_core --export-options export-local-sigs --export | \ 100 | gpg_sphere --import-options import-local-sigs --import 2>&1 | log debug 101 | } 102 | 103 | ######################################################################## 104 | # MAIN 105 | ######################################################################## 106 | 107 | # set unset default variables 108 | AUTHORIZED_USER_IDS="%h/.monkeysphere/authorized_user_ids" 109 | RAW_AUTHORIZED_KEYS="%h/.ssh/authorized_keys" 110 | 111 | # load configuration file 112 | [ -e ${MONKEYSPHERE_AUTHENTICATION_CONFIG:="${SYSCONFIGDIR}/monkeysphere-authentication.conf"} ] \ 113 | && . "$MONKEYSPHERE_AUTHENTICATION_CONFIG" 114 | 115 | # set empty config variable with ones from the environment 116 | LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=$LOG_LEVEL} 117 | KEYSERVER=${MONKEYSPHERE_KEYSERVER:=$KEYSERVER} 118 | CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER} 119 | MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=$MONKEYSPHERE_USER} 120 | MONKEYSPHERE_GROUP=$(get_primary_group "$MONKEYSPHERE_USER") 121 | PROMPT=${MONKEYSPHERE_PROMPT:=$PROMPT} 122 | AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:=$AUTHORIZED_USER_IDS} 123 | RAW_AUTHORIZED_KEYS=${MONKEYSPHERE_RAW_AUTHORIZED_KEYS:=$RAW_AUTHORIZED_KEYS} 124 | STRICT_MODES=${MONKEYSPHERE_STRICT_MODES:=$STRICT_MODES} 125 | 126 | # other variables 127 | REQUIRED_USER_KEY_CAPABILITY=${MONKEYSPHERE_REQUIRED_USER_KEY_CAPABILITY:="a"} 128 | GNUPGHOME_CORE=${MONKEYSPHERE_GNUPGHOME_CORE:="${MADATADIR}/core"} 129 | GNUPGHOME_SPHERE=${MONKEYSPHERE_GNUPGHOME_SPHERE:="${MADATADIR}/sphere"} 130 | CORE_KEYLENGTH=${MONKEYSPHERE_CORE_KEYLENGTH:="2048"} 131 | LOG_PREFIX=${MONKEYSPHERE_LOG_PREFIX:='ms: '} 132 | 133 | # export variables needed in su invocation 134 | export DATE 135 | export LOG_LEVEL 136 | export KEYSERVER 137 | export MONKEYSPHERE_USER 138 | export MONKEYSPHERE_GROUP 139 | export PROMPT 140 | export CHECK_KEYSERVER 141 | export REQUIRED_USER_KEY_CAPABILITY 142 | export GNUPGHOME_CORE 143 | export GNUPGHOME_SPHERE 144 | export GNUPGHOME 145 | export CORE_KEYLENGTH 146 | export LOG_PREFIX 147 | 148 | if [ "$#" -eq 0 ] ; then 149 | usage 150 | failure "Please supply a subcommand." 151 | fi 152 | 153 | # get subcommand 154 | COMMAND="$1" 155 | shift 156 | 157 | case $COMMAND in 158 | 'setup'|'setup'|'s') 159 | source "${MASHAREDIR}/setup" 160 | setup 161 | ;; 162 | 163 | 'update-users'|'update-user'|'update'|'u') 164 | source "${MASHAREDIR}/setup" 165 | setup 166 | source "${MASHAREDIR}/update_users" 167 | OUTPUT_STDOUT= update_users "$@" 168 | ;; 169 | 170 | 'keys-for-user'|'k') 171 | (( $# > 0 )) || failure "Must specify user." 172 | source "${MASHAREDIR}/setup" 173 | setup 174 | source "${MASHAREDIR}/update_users" 175 | OUTPUT_STDOUT=true update_users "$1" 176 | ;; 177 | 178 | 'refresh-keys'|'refresh'|'r') 179 | source "${MASHAREDIR}/setup" 180 | setup 181 | gpg_sphere --keyserver "$KEYSERVER" --refresh-keys 182 | ;; 183 | 184 | 'add-identity-certifier'|'add-id-certifier'|'add-certifier'|'c+') 185 | source "${MASHAREDIR}/setup" 186 | setup 187 | source "${MASHAREDIR}/add_certifier" 188 | add_certifier "$@" 189 | ;; 190 | 191 | 'remove-identity-certifier'|'remove-id-certifier'|'remove-certifier'|'c-') 192 | source "${MASHAREDIR}/setup" 193 | setup 194 | source "${MASHAREDIR}/remove_certifier" 195 | remove_certifier "$@" 196 | ;; 197 | 198 | 'list-identity-certifiers'|'list-id-certifiers'|'list-certifiers'|'list-certifier'|'c') 199 | source "${MASHAREDIR}/setup" 200 | setup 201 | source "${MASHAREDIR}/list_certifiers" 202 | list_certifiers 203 | ;; 204 | 205 | 'diagnostics'|'d') 206 | source "${MASHAREDIR}/setup" 207 | setup 208 | source "${MASHAREDIR}/diagnostics" 209 | diagnostics 210 | ;; 211 | 212 | 'gpg-cmd') 213 | source "${MASHAREDIR}/setup" 214 | setup 215 | gpg_sphere "$@" 216 | ;; 217 | 218 | 'version'|'--version'|'v') 219 | version 220 | ;; 221 | 222 | '--help'|'help'|'-h'|'h'|'?') 223 | usage 224 | ;; 225 | 226 | *) 227 | failure "Unknown command: '$COMMAND' 228 | Try '$PGRM help' for usage." 229 | ;; 230 | esac 231 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/monkeysphere-authentication-keys-for-user: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exec monkeysphere-authentication keys-for-user "$@" 3 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/openpgp2ssh: -------------------------------------------------------------------------------- 1 | share/keytrans -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/pem2openpgp: -------------------------------------------------------------------------------- 1 | share/keytrans -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/checkperms: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -T 2 | 3 | # checkperms: ensure as best we can that a given file can only be 4 | # modified by the given user (or the superuser, naturally). This 5 | # means checking file ownership and permissions all the way back to 6 | # the root directory. Pass the file by its absolute path. 7 | 8 | # example invocation: 9 | 10 | # checkperms dkg /home/dkg/.monkeysphere/authorized_user_ids 11 | 12 | # return values: zero if we believe the file and path can only be 13 | # modified by the user. non-zero otherwise. 14 | 15 | # see StrictModes in sshd_config(5) (and its implementation in 16 | # OpenSSH's secure_filename() in auth.c) for the initial 17 | # inspiration/rationale for this code. 18 | 19 | # Author: 20 | # Daniel Kahn Gillmor 21 | 22 | # Started on: 2009-07-31 11:10:16-0400 23 | 24 | # License: GPL v3 or later 25 | 26 | use strict; 27 | 28 | use Cwd qw(realpath); # found in debian in perl-base 29 | use File::stat; # found in debian in perl-modules 30 | use User::pwent; # found in debian in perl-modules 31 | use Fcntl qw(:mode); # for S_IS* functions (in perl-base) 32 | use File::Basename; # for dirname (in perl-modules) 33 | 34 | my $username = shift; 35 | my $path = shift; 36 | 37 | defined($username) or die "You must pass a username and an absolute path.\n"; 38 | defined($path) or die "You must pass a username and an absolute path.\n"; 39 | 40 | my $pw = getpwnam($username) or die "no such user $username\n"; 41 | $path =~ m#^/# or die "path was not absolute (did not start with /)\n"; 42 | 43 | sub mslog { 44 | my $level = shift; 45 | 46 | # FIXME: check and compare the log level 47 | if ($ENV{LOG_LEVEL} eq 'DEBUG') { 48 | my $format = shift; 49 | my $out = sprintf($format, @_); 50 | 51 | $out =~ s/^/$ENV{LOG_PREFIX}/ ; 52 | 53 | printf STDERR "%s", $out; 54 | } 55 | } 56 | 57 | ## return undef if permissions are OK. otherwise return an error string 58 | sub permissions_ok { 59 | my $user = shift; 60 | my $path = shift; 61 | 62 | # if we can't even stat the path, the permissions are not ok: 63 | my $stat = lstat($path) or return "cannot stat '$path'"; 64 | 65 | while (S_ISLNK($stat->mode)) { 66 | my $newpath = realpath($path) or return "cannot trace symlink '$path'"; 67 | mslog('DEBUG', "tracing link %s to %s\n", $path, $newpath); 68 | $path = $newpath; 69 | $stat = lstat($path) or return "cannot stat '$path'"; 70 | } 71 | mslog('DEBUG', "checking '%s'\n", $path); 72 | 73 | if (($stat->uid != $user->uid) && 74 | ($stat->uid != 0)) { 75 | return sprintf("improper ownership on '%s': owner ID %d is neither %s (ID %d) nor the superuser", 76 | $path, $stat->uid, $user->name, $user->uid); 77 | } 78 | 79 | if ($stat->mode & S_IWGRP) { 80 | return sprintf("improper group writability on '%s'", $path); 81 | } 82 | 83 | if ($stat->mode & S_IWOTH) { 84 | return sprintf("improper other writability on '%s'", $path); 85 | } 86 | 87 | # see the rationalization in secure_filename() in auth.c in the 88 | # OpenSSH sources for an explanation of this bailout (see also 89 | # monkeysphere #675): 90 | if ($path eq $user->dir) { 91 | mslog('DEBUG', "stopping at %s's home directory '%s'\n", $user->name, $path); 92 | return undef; 93 | } 94 | 95 | my $nextlevel = dirname($path); 96 | if ($path eq $nextlevel) { # we bottom out at the root (/ in UNIX) 97 | return undef; 98 | } 99 | return permissions_ok($user, $nextlevel); 100 | } 101 | 102 | my $err = permissions_ok($pw, $path); 103 | 104 | if (defined($err)) { 105 | printf(STDERR "%s%s\n", $ENV{LOG_PREFIX}, $err); 106 | 107 | exit(1); 108 | } else { 109 | exit(0); 110 | } 111 | 112 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/defaultenv: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Shared sh variables for the monkeysphere 5 | # 6 | # Written by 7 | # Jameson Rollins 8 | # 9 | # Copyright 2009, released under the GPL, version 3 or later 10 | 11 | # managed directories 12 | SYSCONFIGDIR=${MONKEYSPHERE_SYSCONFIGDIR:-"__SYSCONFDIR_PREFIX__/etc/monkeysphere"} 13 | export SYSCONFIGDIR 14 | SYSDATADIR=${MONKEYSPHERE_SYSDATADIR:-"__SYSDATADIR_PREFIX__/monkeysphere"} 15 | export SYSDATADIR 16 | 17 | # default log level 18 | LOG_LEVEL="INFO" 19 | 20 | # default keyserver 21 | KEYSERVER="pool.sks-keyservers.net" 22 | 23 | # whether or not to check keyservers by default 24 | CHECK_KEYSERVER="true" 25 | 26 | # whether or not to care about extra write bits on sensitive files 27 | # like known_hosts, authorized_keys, and authorized_user_ids 28 | STRICT_MODES="true" 29 | 30 | # default monkeysphere user 31 | MONKEYSPHERE_USER="monkeysphere" 32 | 33 | # default about whether or not to prompt 34 | PROMPT="true" 35 | 36 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/m/gen_subkey: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere gen-subkey subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # generate a subkey with the 'a' usage flags set 15 | 16 | gen_subkey(){ 17 | local keyLength 18 | local gpgSecOut 19 | local keyID 20 | local editCommands 21 | local fifoDir 22 | local keyType 23 | 24 | # get options 25 | while true ; do 26 | case "$1" in 27 | -l|--length) 28 | keyLength="$2" 29 | shift 2 30 | ;; 31 | *) 32 | if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then 33 | failure "Unknown option '$1'. 34 | Type '$PGRM help' for usage." 35 | fi 36 | break 37 | ;; 38 | esac 39 | done 40 | 41 | # check that the keyID is unique 42 | keyID=$(check_gpg_sec_key_id "$@") 43 | 44 | # check that an authentication subkey does not already exist 45 | check_gpg_authentication_subkey "$keyID" 46 | 47 | # determine which keyType to use from gpg version 48 | keyType=7 49 | case $(gpg --version | head -1 | awk '{ print $3 }' | cut -d. -f1) in 50 | 1) 51 | if is_gpg_version_greater_equal 1.4.10 ; then 52 | keyType=8 53 | fi 54 | ;; 55 | 2) 56 | if is_gpg_version_greater_equal 2.0.13 ; then 57 | keyType=8 58 | fi 59 | ;; 60 | *) 61 | keyType=8 62 | ;; 63 | esac 64 | 65 | # generate the list of commands that will be passed to edit-key 66 | editCommands="addkey 67 | $keyType 68 | S 69 | E 70 | A 71 | Q 72 | $keyLength 73 | 0 74 | save" 75 | 76 | # setup the temp fifo dir for retrieving the key password 77 | log debug "creating password fifo..." 78 | fifoDir=$(msmktempdir) 79 | (umask 077 && mkfifo "$fifoDir/pass") 80 | 81 | # FIXME: are we adequately cleaning up any trailing gpg process here? 82 | trap "rm -rf $fifoDir; kill %% || true" EXIT 83 | echo "$editCommands" | gpg_user --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --edit-key "$keyID" & 84 | 85 | log debug "Prompting for passphrase" 86 | # FIXME: this needs to fail more gracefully if the passphrase is incorrect 87 | passphrase_prompt "Please enter your passphrase for $keyID: " "$fifoDir/pass" 88 | log info "Generating subkey. This may take a long time..." 89 | 90 | trap - EXIT 91 | rm -rf "$fifoDir" 92 | wait 93 | log verbose "done." 94 | } 95 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/m/import_subkey: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere import-subkey subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # import an existing ssh key as a gpg subkey 15 | 16 | ## 2009-02-20 00:49:11-0500: This is not implemented yet, because we 17 | ## don't currently have a good way to manipulate the user's OpenPGP 18 | ## secret key such that we could make a proper subkey binding 19 | ## signature. 20 | 21 | import_subkey() { 22 | local sshKeyFile 23 | local keyID 24 | local gpgSecOut 25 | local fifoDir 26 | 27 | # FIXME: implement! 28 | failure "import-subkey is not implemented yet. We welcome patches. Sorry!" 29 | 30 | sshKeyFile="$1" 31 | shift 32 | 33 | # check that key file specified 34 | if [ -z "$sshKeyFile" ] ; then 35 | failure "Must specify ssh key file to import, or specify '-' for stdin." 36 | fi 37 | 38 | # check that the keyID is unique 39 | keyID=$(check_gpg_sec_key_id "$@") 40 | 41 | # check that an authentication subkey does not already exist 42 | check_gpg_authentication_subkey "$keyID" 43 | 44 | # setup the temp fifo dir for retrieving the key password 45 | log debug "creating password fifo..." 46 | fifoDir=$(msmktempdir) 47 | trap "rm -rf $fifoDir" EXIT 48 | (umask 077 && mkfifo "$fifoDir/pass") 49 | 50 | # import ssh key to as authentication subkey 51 | if [ "$sshKeyFile" = '-' ] ; then 52 | log verbose "importing ssh key from stdin..." 53 | PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" \ 54 | | gpg_user --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --import & 55 | else 56 | log verbose "importing ssh key from file '$sshKeyFile'..." 57 | PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" <"$sshKeyFile" \ 58 | | gpg_user --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --import & 59 | fi 60 | 61 | # get the password if needed 62 | passphrase_prompt "Please enter your passphrase for $keyID: " "$fifoDir/pass" 63 | 64 | trap - EXIT 65 | rm -rf "$fifoDir" 66 | wait 67 | log verbose "done." 68 | } 69 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/m/keys_for_userid: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere keys-for-userid subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2010, and are all released under the GPL, version 12 | # 3 or later. 13 | 14 | keys_for_userid() { 15 | FILE_TYPE='raw' process_keys_for_file - "$@" 16 | } 17 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/m/ssh_proxycommand: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere ssh-proxycommand subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Daniel Kahn Gillmor 9 | # 10 | # They are Copyright 2008-2009, and are all released under the GPL, 11 | # version 3 or later. 12 | 13 | # This is meant to be run as an ssh ProxyCommand to initiate a 14 | # monkeysphere known_hosts update before an ssh connection to host is 15 | # established. Can be added to ~/.ssh/config as follows: 16 | # ProxyCommand monkeysphere ssh-proxycommand %h %p 17 | 18 | # the ssh proxycommand function itself 19 | ssh_proxycommand() { 20 | local connect='true' 21 | local HOST 22 | local PORT 23 | local HOSTP 24 | local URI 25 | 26 | if [[ "$1" == '--no-connect' ]] ; then 27 | connect='false' 28 | shift 1 29 | fi 30 | 31 | HOST="$1" 32 | PORT="$2" 33 | 34 | if [ -z "$HOST" ] ; then 35 | log error "Host not specified." 36 | usage 37 | exit 255 38 | fi 39 | if [ -z "$PORT" ] ; then 40 | PORT=22 41 | fi 42 | 43 | # set the host URI 44 | if [ "$PORT" != '22' ] ; then 45 | HOSTP="${HOST}:${PORT}" 46 | else 47 | HOSTP="${HOST}" 48 | fi 49 | URI="ssh://${HOSTP}" 50 | 51 | # passed HOST/PORT/HOSTP/URI 52 | validate_monkeysphere 53 | 54 | # exec a netcat passthrough to host for the ssh connection 55 | if [[ "$connect" == 'true' ]] ; then 56 | if (type nc &>/dev/null); then 57 | exec nc "$HOST" "$PORT" 58 | elif (type socat &>/dev/null); then 59 | exec socat STDIO "TCP:$HOST:$PORT" 60 | else 61 | echo "Neither netcat nor socat found -- could not complete monkeysphere-ssh-proxycommand connection to $HOST:$PORT" >&2 62 | exit 255 63 | fi 64 | fi 65 | } 66 | 67 | validate_monkeysphere() { 68 | local hostKey 69 | 70 | # specify keyserver checking. the behavior of this proxy command 71 | # is intentionally different than that of running monkeyesphere 72 | # normally, and keyserver checking is intentionally done under 73 | # certain circumstances. This can be overridden by setting the 74 | # MONKEYSPHERE_CHECK_KEYSERVER environment variable, or by setting 75 | # the CHECK_KEYSERVER variable in the monkeysphere.conf file. 76 | 77 | # if the host is in the gpg keyring... 78 | if gpg_user --list-key ="${URI}" &>/dev/null ; then 79 | # do not check the keyserver 80 | CHECK_KEYSERVER=${CHECK_KEYSERVER:="false"} 81 | 82 | # if the host is NOT in the keyring... 83 | else 84 | # FIXME: what about system-wide known_hosts file (/etc/ssh/known_hosts)? 85 | 86 | if [ -r "$KNOWN_HOSTS" ]; then 87 | # look up the host key is found in the known_hosts file... 88 | if (type ssh-keygen &>/dev/null) ; then 89 | hostKey=$(ssh-keygen -F "$HOST" -f "$KNOWN_HOSTS" 2>/dev/null) 90 | else 91 | # FIXME: we're not dealing with digested known_hosts 92 | # if we don't have ssh-keygen 93 | 94 | # But we could do this without needing ssh-keygen. 95 | # hashed known_hosts looks like: |1|X|Y where 1 means 96 | # SHA1 (nothing else is defined in openssh sources), X 97 | # is the salt (same length as the digest output), 98 | # base64-encoded, and Y is the digested hostname (also 99 | # base64-encoded). 100 | 101 | # see hostfile.{c,h} in openssh sources. 102 | 103 | hostKey=$(cut -f1 -d\ < .ssh/known_hosts | tr ',' '\n' | grep -Fx -e "$HOST" || :) 104 | fi 105 | fi 106 | 107 | if [ "$hostKey" ] ; then 108 | # do not check the keyserver 109 | # FIXME: more nuanced checking should be done here to properly 110 | # take into consideration hosts that join monkeysphere by 111 | # converting an existing and known ssh key 112 | CHECK_KEYSERVER=${CHECK_KEYSERVER:="false"} 113 | 114 | # if the host key is not found in the known_hosts file... 115 | else 116 | # check the keyserver 117 | CHECK_KEYSERVER=${CHECK_KEYSERVER:="true"} 118 | fi 119 | fi 120 | 121 | # finally look in the MONKEYSPHERE_ environment variable for a 122 | # CHECK_KEYSERVER setting to override all else 123 | CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER} 124 | 125 | declare -i KEYS_PROCESSED=0 126 | declare -i KEYS_VALID=0 127 | 128 | # update the known_hosts file for the host 129 | source "${MSHAREDIR}/update_known_hosts" 130 | update_known_hosts "$HOSTP" 131 | 132 | if ((KEYS_PROCESSED > 0)) && ((KEYS_VALID == 0)) ; then 133 | log debug "output ssh marginal ui..." 134 | output_no_valid_key 135 | fi 136 | 137 | # FIXME: what about the case where monkeysphere successfully finds 138 | # a valid key for the host and adds it to the known_hosts file, 139 | # but a different non-monkeysphere key for the host already exists 140 | # in the known_hosts, and it is this non-ms key that is offered by 141 | # the host? monkeysphere will succeed, and the ssh connection 142 | # will succeed, and the user will be left with the impression that 143 | # they are dealing with a OpenPGP/PKI host key when in fact they 144 | # are not. should we use ssh-keyscan to compare the keys first? 145 | } 146 | 147 | # output the key info, including the RSA fingerprint 148 | show_key_info() { 149 | local keyid="$1" 150 | local sshKeyGPGFile 151 | local sshFingerprint 152 | local gpgSigOut 153 | local otherUids 154 | 155 | # get the ssh key of the gpg key 156 | sshFingerprint=$(gpg2ssh "$keyid" | "$SYSSHAREDIR/keytrans" sshfpr) 157 | 158 | # get the sigs for the matching key 159 | gpgSigOut=$(gpg_user --check-sigs \ 160 | --list-options show-uid-validity \ 161 | "$keyid") 162 | 163 | echo | log info 164 | 165 | # output the sigs, but only those on the user ID 166 | # we are looking for 167 | echo "$gpgSigOut" | awk ' 168 | { 169 | if (match($0,"^pub")) { print; } 170 | if (match($0,"^uid")) { ok=0; } 171 | if (match($0,"^uid.*'$userID'$")) { ok=1; print; } 172 | if (ok) { if (match($0,"^sig")) { print; } } 173 | } 174 | ' 175 | 176 | # output ssh fingerprint 177 | cat </dev/null ) ; then 214 | # retrieve the ssh key being offered by the host 215 | sshKeyOffered=$(ssh-keyscan -t rsa -p "$PORT" "$HOST" 2>/dev/null \ 216 | | awk '{ print $2, $3 }') 217 | fi 218 | 219 | # get the gpg info for userid 220 | gpgOut=$(gpg_user --list-key --with-colons \ 221 | --with-fingerprint --with-fingerprint \ 222 | ="$userID" 2>/dev/null) 223 | 224 | # output header 225 | log info < 0)) ; then 297 | log info < 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # try to add all authentication subkeys to the agent 15 | 16 | # FIXME: what if you only want to add one authentication subkey to the 17 | # agent? 18 | 19 | subkey_to_ssh_agent() { 20 | local sshaddresponse=0 21 | local secretkeys 22 | local authsubkeys 23 | local workingdir 24 | local keysuccess=0 25 | local subkey 26 | local publine 27 | local kname 28 | 29 | # if there's no agent running, don't bother: 30 | if [ -z "$SSH_AUTH_SOCK" ] || ! type ssh-add >/dev/null ; then 31 | failure "No ssh-agent available." 32 | fi 33 | 34 | # and if it looks like it's running, but we can't actually talk to 35 | # it, bail out: 36 | ssh-add -l >/dev/null || sshaddresponse="$?" 37 | if [ "$sshaddresponse" = "2" ]; then 38 | failure "Could not connect to ssh-agent" 39 | fi 40 | 41 | # if the MONKEYSPHERE_SUBKEYS_FOR_AGENT variable is set, use the 42 | # keys specified there 43 | if [ "$MONKEYSPHERE_SUBKEYS_FOR_AGENT" ] ; then 44 | authsubkeys="$MONKEYSPHERE_SUBKEYS_FOR_AGENT" 45 | 46 | # otherwise find all authentication-capable subkeys and use those 47 | else 48 | # get list of secret keys 49 | # (to work around bug https://bugs.g10code.com/gnupg/issue945): 50 | secretkeys=$(gpg_user --list-secret-keys --with-colons \ 51 | --fingerprint | \ 52 | grep '^fpr:' | cut -f10 -d: | awk '{ print "0x" $1 "!" }') 53 | 54 | if [ -z "$secretkeys" ]; then 55 | failure "You have no secret keys in your keyring! 56 | You might want to run 'gpg --gen-key'." 57 | fi 58 | 59 | authsubkeys=$(gpg_user --list-secret-keys --with-colons \ 60 | --fingerprint --fingerprint $secretkeys | \ 61 | cut -f1,5,10,12 -d: | grep -A1 '^ssb:[^:]*::[^:]*a[^:]*$' | \ 62 | grep '^fpr::' | cut -f3 -d: | sort -u) 63 | 64 | if [ -z "$authsubkeys" ]; then 65 | failure "no authentication-capable subkeys available. 66 | You might want to run 'monkeysphere gen-subkey'." 67 | fi 68 | fi 69 | 70 | workingdir=$(msmktempdir) 71 | trap "rm -rf $workingdir" EXIT 72 | umask 077 73 | mkfifo "$workingdir/passphrase" 74 | 75 | # FIXME: we're currently allowing any other options to get passed 76 | # through to ssh-add. should we limit it to known ones? For 77 | # example: -d or -c and/or -t 78 | 79 | for subkey in $authsubkeys; do 80 | # test that the subkey has proper capability 81 | capability=$(gpg_user --list-secret-keys --with-colons \ 82 | --fingerprint --fingerprint "0x${subkey}!" \ 83 | | egrep -B 1 "^fpr:::::::::${subkey}:$" | grep "^ssb:" | cut -d: -f12) 84 | if ! check_capability "$capability" 'a' ; then 85 | log error "Did not find authentication-capable subkey with key ID '$subkey'." 86 | continue 87 | fi 88 | 89 | # choose a label by which this key will be known in the agent: 90 | # we are labelling the key by User ID instead of by 91 | # fingerprint, but filtering out all / characters to make sure 92 | # the filename is legit. 93 | 94 | # FIXME: this assumes that the first listed uid is the primary 95 | # UID. does gpg guarantee that? is there some better way to 96 | # get this info? 97 | primaryuid=$(gpg_user --with-colons --list-key "0x${subkey}!" | grep '^uid:' | head -n1 | cut -f10 -d: | tr -d /) 98 | 99 | #kname="[monkeysphere] $primaryuid" 100 | kname="${primaryuid:-Monkeysphere Key 0x${subkey}}" 101 | 102 | if [ "$1" = '-d' ]; then 103 | # we're removing the subkey: 104 | gpg_user --export --no-armor "0x${subkey}!" | openpgp2ssh "$subkey" > "$workingdir/$kname" 105 | (cd "$workingdir" && ssh-add -d "$kname") || keysuccess="$?" 106 | else 107 | # we're adding the subkey: 108 | mkfifo "$workingdir/$kname" 109 | gpg_user --passphrase-fd 3 3<"$workingdir/passphrase" \ 110 | --export-options export-reset-subkey-passwd,export-minimal,no-export-attributes \ 111 | --export-secret-subkeys --no-armor "0x${subkey}!" | openpgp2ssh "$subkey" > "$workingdir/$kname" & 112 | (cd "$workingdir" && DISPLAY=nosuchdisplay SSH_ASKPASS=/bin/false ssh-add "$@" "$kname" 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2010, and are all released under the GPL, version 12 | # 3 or later. 13 | 14 | update_authorized_keys() { 15 | local newUmask 16 | local tmpFile 17 | 18 | if [ ! -s "$AUTHORIZED_USER_IDS" ] ; then 19 | log error "empty or absent authorized_user_ids file." 20 | failure 21 | fi 22 | check_key_file_permissions $(whoami) "$AUTHORIZED_USER_IDS" \ 23 | || failure "Bad permissions governing authorized_user_ids file '$AUTHORIZED_USER_IDS'" 24 | 25 | # touch the authorized_keys file so that the file permission check 26 | # below won't fail upon not finding the file 27 | touch_key_file_or_fail "$AUTHORIZED_KEYS" 28 | check_key_file_permissions $(whoami) "$AUTHORIZED_KEYS" \ 29 | || failure "Bad permissions governing authorized_keys file $AUTHORIZED_KEYS" 30 | 31 | lock create "$AUTHORIZED_KEYS" 32 | 33 | # FIXME: we're discarding any pre-existing EXIT trap; is this bad? 34 | trap "log debug TRAP; lock remove $AUTHORIZED_KEYS" EXIT 35 | 36 | tmpFile=$(mktemp "${AUTHORIZED_KEYS}.monkeysphere.XXXXXX") 37 | 38 | trap "log debug TRAP; lock remove $AUTHORIZED_KEYS; rm -f $tmpFile" EXIT 39 | 40 | # remove any monkeysphere lines from authorized_keys file this is 41 | # to insure that that all old authorized keys that are no longer 42 | # authorized are removed 43 | log debug "removing old monkeysphere lines..." 44 | remove_monkeysphere_lines <"$AUTHORIZED_KEYS" >"$tmpFile" || true 45 | 46 | process_authorized_user_ids "$tmpFile" \ 47 | < "$AUTHORIZED_USER_IDS" 48 | 49 | if [ "$(file_hash "$AUTHORIZED_KEYS")" != "$(file_hash "$tmpFile")" ] ; then 50 | mv -f "$tmpFile" "$AUTHORIZED_KEYS" 51 | log verbose "authorized_keys file updated." 52 | else 53 | rm -f "$tmpFile" 54 | fi 55 | 56 | lock remove "$AUTHORIZED_KEYS" 57 | 58 | trap - EXIT 59 | } 60 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/m/update_known_hosts: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere update_known_hosts subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2010, and are all released under the GPL, version 12 | # 3 or later. 13 | 14 | # update the known_hosts file for a set of hosts listed on command 15 | # line 16 | update_known_hosts() { 17 | local tmpFile 18 | local host 19 | 20 | # touch the known_hosts file so that the file permission check 21 | # below won't fail upon not finding the file 22 | touch_key_file_or_fail "$KNOWN_HOSTS" 23 | check_key_file_permissions $(whoami) "$KNOWN_HOSTS" \ 24 | || failure "Bad permissions governing known_hosts file $KNOWN_HOSTS" 25 | 26 | lock create "$KNOWN_HOSTS" 27 | 28 | # FIXME: we're discarding any pre-existing EXIT trap; is this bad? 29 | trap "log debug TRAP; lock remove $KNOWN_HOSTS" EXIT 30 | 31 | tmpFile=$(mktemp "${KNOWN_HOSTS}.monkeysphere.XXXXXX") 32 | 33 | trap "log debug TRAP; lock remove $KNOWN_HOSTS; rm -f $tmpFile" EXIT 34 | 35 | cat "$KNOWN_HOSTS" >"$tmpFile" 36 | 37 | for host ; do 38 | FILE_TYPE='known_hosts' process_keys_for_file "$tmpFile" "ssh://${host}" 39 | 40 | lock touch "$KNOWN_HOSTS" 41 | done 42 | 43 | if [ "$(file_hash "$KNOWN_HOSTS")" != "$(file_hash "$tmpFile")" ] ; then 44 | mv -f "$tmpFile" "$KNOWN_HOSTS" 45 | log debug "known_hosts file updated." 46 | else 47 | rm -f "$tmpFile" 48 | fi 49 | 50 | lock remove "$KNOWN_HOSTS" 51 | 52 | trap - EXIT 53 | } 54 | 55 | # process hosts from a known_hosts file 56 | process_known_hosts() { 57 | local hosts 58 | 59 | if [ ! -e "$KNOWN_HOSTS" ] ; then 60 | failure "known_hosts file '$KNOWN_HOSTS' does not exist." 61 | fi 62 | 63 | log debug "processing known_hosts file:" 64 | log debug " $KNOWN_HOSTS" 65 | 66 | hosts=$(meat "$KNOWN_HOSTS" | cut -d ' ' -f 1 | grep -v '^|.*$' | tr , ' ' | tr '\n' ' ') 67 | 68 | if [ -z "$hosts" ] ; then 69 | log debug "no hosts to process." 70 | return 71 | fi 72 | 73 | # take all the hosts from the known_hosts file (first 74 | # field), grep out all the hashed hosts (lines starting 75 | # with '|')... 76 | update_known_hosts $hosts 77 | } 78 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/ma/add_certifier: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere authentication add-certifier subcommand 5 | # 6 | # This function adds a certifier whose signatures will be used to 7 | # calculate validity of keys used to connect to user accounts on the 8 | # server. The specified certifier key is first retrieved from the Web 9 | # of Trust with the monkeysphere-user-controlled gpg_sphere keyring. 10 | # Once then new key is retrieved, it is imported into the core 11 | # keyring. The gpg_core then ltsigns the key with the desired trust 12 | # level, and then the key is exported back to the gpg_sphere keyring. 13 | # The gpg_sphere has ultimate owner trust of the core key, so the core 14 | # ltsigs on the new certifier key can then be used by gpg_sphere 15 | # calculate validity for keys inserted in the authorized_keys file. 16 | # 17 | # This is all to keep the monkeysphere user that connects to the 18 | # keyservers from accessing the core secret key. 19 | # 20 | # The monkeysphere scripts are written by: 21 | # Jameson Rollins 22 | # Jamie McClelland 23 | # Daniel Kahn Gillmor 24 | # 25 | # They are Copyright 2008-2009, and are all released under the GPL, 26 | # version 3 or later. 27 | 28 | add_certifier() { 29 | 30 | local domain= 31 | local trust=full 32 | local depth=1 33 | local keyID 34 | local fingerprint 35 | local ltsignCommand 36 | local trustval 37 | 38 | # get options 39 | while true ; do 40 | case "$1" in 41 | -n|--domain) 42 | domain="$2" 43 | shift 2 44 | ;; 45 | -t|--trust) 46 | trust="$2" 47 | shift 2 48 | ;; 49 | -d|--depth) 50 | depth="$2" 51 | shift 2 52 | ;; 53 | -) 54 | break 55 | ;; 56 | *) 57 | if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then 58 | failure "Unknown option '$1'. 59 | Type '$PGRM help' for usage." 60 | fi 61 | break 62 | ;; 63 | esac 64 | done 65 | 66 | keyID="$1" 67 | 68 | # check that key ID or file is specified 69 | if [ -z "$keyID" ] ; then 70 | failure "You must specify the key ID of a key to add, or specify a file to read the key from." 71 | fi 72 | 73 | # check the trust value 74 | case "$trust" in 75 | 'marginal') 76 | trustval=1 77 | ;; 78 | 'full') 79 | trustval=2 80 | ;; 81 | *) 82 | failure "Trust value requested ('$trust') was unclear (only 'marginal' or 'full' are supported)." 83 | ;; 84 | esac 85 | 86 | # if file is specified 87 | if [ -f "$keyID" -o "$keyID" = '-' ] ; then 88 | # load the key from stdin 89 | if [ "$keyID" = '-' ] ; then 90 | # make a temporary file to hold the key from stdin 91 | keyID=$(msmktempfile) 92 | trap "rm -f $keyID" EXIT 93 | log verbose "reading key from stdin..." 94 | cat > "$keyID" 95 | 96 | # load the key from the file 97 | elif [ -f "$keyID" ] ; then 98 | log verbose "reading key from file '$keyID'..." 99 | fi 100 | 101 | # check the key is ok as monkeysphere user before loading 102 | log debug "checking keys in file..." 103 | fingerprint=$(su_monkeysphere_user \ 104 | ". ${SYSSHAREDIR}/common; list_primary_fingerprints" < "$keyID") 105 | 106 | if [ $(printf "%s" "$fingerprint" | egrep -c '^[A-F0-9]{40}$') -ne 1 ] ; then 107 | failure "There was not exactly one gpg key in the file." 108 | fi 109 | 110 | # load the key 111 | gpg_sphere --import <"$keyID" 2>/dev/null \ 112 | || failure "could not read key from '$keyID'" 113 | 114 | # else, get the key from the keyserver 115 | else 116 | log verbose "searching keyserver $KEYSERVER for keyID $keyID..." 117 | gpg_sphere --keyserver "$KEYSERVER" --recv-key "0x${keyID}!" \ 118 | || failure "Could not receive a key with this ID from the '$KEYSERVER' keyserver." 119 | 120 | # get the full fingerprint of new certifier key 121 | log debug "getting fingerprint of certifier key..." 122 | fingerprint=$(gpg_sphere --list-key --with-colons --with-fingerprint "0x${keyID}!" \ 123 | | grep '^fpr:' | cut -d: -f10) 124 | 125 | # test that there is only a single fingerprint 126 | if (( $(echo "$fingerprint" | wc -l) != 1 )) ; then 127 | cat <&2 140 | read OK; OK=${OK:-Y} 141 | if [ "${OK/y/Y}" != 'Y' ] ; then 142 | failure "Identity certifier not added." 143 | fi 144 | else 145 | log debug "adding key without prompting." 146 | fi 147 | fi 148 | 149 | # export the key to the core keyring so that the core can sign the 150 | # new certifier key 151 | log debug "loading key into core keyring..." 152 | gpg_sphere --export "0x${fingerprint}!" | gpg_core --import 153 | 154 | # edit-key script to ltsign key 155 | # NOTE: *all* user IDs will be ltsigned 156 | ltsignCommand="ltsign 157 | y 158 | $trustval 159 | $depth 160 | $domain 161 | y 162 | save" 163 | # end script 164 | 165 | # core ltsigns the newly imported certifier key 166 | log debug "executing core ltsign script..." 167 | if echo "$ltsignCommand" | \ 168 | gpg_core --command-fd 0 --edit-key "0x${fingerprint}!" ; then 169 | 170 | # transfer the new sigs back to the sphere keyring 171 | gpg_core_sphere_sig_transfer 172 | 173 | # update the sphere trustdb 174 | log debug "updating sphere trustdb..." 175 | gpg_sphere --check-trustdb 2>&1 | log debug 176 | 177 | log info "Identity certifier added." 178 | else 179 | failure "Problem adding identify certifier." 180 | fi 181 | 182 | } 183 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/ma/diagnostics: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere authentication diagnostics subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # check on the status and validity of the key and public certificates 15 | 16 | diagnostics() { 17 | 18 | local seckey 19 | local keysfound 20 | local curdate 21 | local warnwindow 22 | local warndate 23 | local create 24 | local expire 25 | local uid 26 | local fingerprint 27 | local badhostkeys 28 | local sshd_config 29 | local problemsfound=0 30 | 31 | report_cruft 32 | 33 | if ! id monkeysphere >/dev/null ; then 34 | echo "! No monkeysphere user found! Please create a monkeysphere system user with bash as its shell." 35 | problemsfound=$(($problemsfound+1)) 36 | fi 37 | 38 | if ! [ -d "$SYSDATADIR" ] ; then 39 | echo "! no $SYSDATADIR directory found. Please create it." 40 | problemsfound=$(($problemsfound+1)) 41 | fi 42 | 43 | echo "Checking for authentication directory..." 44 | if ! [ -d "$MADATADIR" ] ; then 45 | echo "! No authentication data directory found." 46 | echo " - Recommendation: run 'monkeysphere-authentication setup'" 47 | exit 48 | fi 49 | 50 | # FIXME: what's the correct, cross-platform way to determine where 51 | # sshd_config lives? 52 | sshd_config=/etc/ssh/sshd_config 53 | 54 | seckey=$(gpg_core --list-secret-keys --fingerprint --with-colons) 55 | keysfound=$(echo "$seckey" | grep -c ^sec:) 56 | curdate=$(date +%s) 57 | # warn when anything is 2 months away from expiration 58 | warnwindow='2 months' 59 | warndate=$(advance_date $warnwindow +%s) 60 | 61 | echo "Checking core GPG key..." 62 | if (( "$keysfound" < 1 )); then 63 | echo "! No core key found." 64 | echo " - Recommendation: run 'monkeysphere-authentication setup'" 65 | problemsfound=$(($problemsfound+1)) 66 | elif (( "$keysfound" > 1 )); then 67 | echo "! More than one core key found?" 68 | # FIXME: recommend a way to resolve this 69 | problemsfound=$(($problemsfound+1)) 70 | else 71 | create=$(echo "$seckey" | grep ^sec: | cut -f6 -d:) 72 | expire=$(echo "$seckey" | grep ^sec: | cut -f7 -d:) 73 | fingerprint=$(echo "$seckey" | grep ^fpr: | head -n1 | cut -f10 -d:) 74 | # check for key expiration: 75 | if [ "$expire" ]; then 76 | if (( "$expire" < "$curdate" )); then 77 | echo "! Core key is expired." 78 | echo " - Recommendation: ???" 79 | problemsfound=$(($problemsfound+1)) 80 | elif (( "$expire" < "$warndate" )); then 81 | echo "! Core key expires in less than $warnwindow:" $(advance_date $(( $expire - $curdate )) seconds +%F) 82 | echo " - Recommendation: ???" 83 | problemsfound=$(($problemsfound+1)) 84 | fi 85 | fi 86 | 87 | # and weirdnesses: 88 | if [ "$create" ] && (( "$create" > "$curdate" )); then 89 | echo "! Core key was created in the future(?!). Is your clock correct?" 90 | echo " - Recommendation: Check clock ($(date +%F_%T)); use NTP?" 91 | problemsfound=$(($problemsfound+1)) 92 | fi 93 | 94 | fi 95 | 96 | # FIXME: look at the ownership/privileges of the various keyrings, 97 | # directories housing them, etc (what should those values be? can 98 | # we make them as minimal as possible?) 99 | 100 | # FIXME: look to see that the ownertrust rules are set properly on the 101 | # sphere keyring 102 | 103 | # make sure that at least one identity certifier exists 104 | echo 105 | echo "Checking for Identity Certifiers..." 106 | if ! ( monkeysphere-authentication list-identity-certifiers | egrep '^[A-F0-9]{40}:' >/dev/null ) ; then 107 | echo "! No Identity Certifiers found!" 108 | echo " - Recommendation: once you know who should be able to certify the identities of 109 | connecting users, you should add their key, with: 110 | monkeysphere-authentication add-identity-certifier" 111 | problemsfound=$(($problemsfound+1)) 112 | fi 113 | 114 | # FIXME: look at the timestamps on the monkeysphere-generated 115 | # authorized_keys files -- warn if they seem out-of-date. 116 | 117 | # FIXME: check for a cronjob that updates monkeysphere-generated 118 | # authorized_keys? 119 | 120 | echo 121 | echo "Checking for Monkeysphere-enabled public-key authentication for users ..." 122 | # Ensure that User ID authentication is enabled: 123 | if ! grep -q "^AuthorizedKeysFile[[:space:]]\+${SYSDATADIR}/authorized_keys/%u$" "$sshd_config"; then 124 | echo "! $sshd_config does not point to monkeysphere authorized keys." 125 | echo " - Recommendation: add a line to $sshd_config: 'AuthorizedKeysFile ${SYSDATADIR}/authorized_keys/%u'" 126 | problemsfound=$(($problemsfound+1)) 127 | fi 128 | if badauthorizedkeys=$(grep -i '^AuthorizedKeysFile' "$sshd_config" | grep -v "^AuthorizedKeysFile[[:space:]]\+${SYSDATADIR}/authorized_keys/%u$") ; then 129 | echo "! $sshd_config refers to non-monkeysphere authorized_keys files:" 130 | echo "$badauthorizedkeys" 131 | echo " - Recommendation: remove the above AuthorizedKeysFile lines from $sshd_config" 132 | problemsfound=$(($problemsfound+1)) 133 | fi 134 | 135 | if [ "$problemsfound" -gt 0 ]; then 136 | echo "When the above $problemsfound issue"$(if [ "$problemsfound" -eq 1 ] ; then echo " is" ; else echo "s are" ; fi)" resolved, please re-run:" 137 | echo " monkeysphere-authentication diagnostics" 138 | else 139 | echo "Everything seems to be in order!" 140 | fi 141 | 142 | } 143 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/ma/list_certifiers: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere authentication list-certifiers subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # list the host certifiers 15 | 16 | list_certifiers() { 17 | 18 | local keys 19 | local key 20 | local authfpr 21 | local keyfpr 22 | local uid 23 | local printedfpr 24 | 25 | # find trusted keys in sphere keychain 26 | log debug "finding trusted keys..." 27 | 28 | # FIXME: this assumes that the keygrip (16 hex chars) is unique; we're 29 | # only searching by keygrip at the moment. 30 | 31 | authgrip=$(core_fingerprint | cut -b 25-40) 32 | 33 | # We're walking the list of known signatures, and extracting all trust 34 | # signatures made by the core fingerprint and known to the sphere 35 | # keyring. 36 | 37 | # for each one of these, we're printing (colon-delimited): the 38 | # fingerprint, the trust depth, the trust level (60 == marginal, 120 39 | # == full), and the domain regex (if any): 40 | 41 | gpg_sphere --fingerprint --with-colons --check-sigs | \ 42 | cut -f 1,2,5,8,9,10 -d: | \ 43 | egrep '^(fpr:::::|uat:|uid:|sig:!:'"$authgrip"':[[:digit:]]+ [[:digit:]]+:)' | \ 44 | while IFS=: read -r type validity grip trustparams trustdomain fpr ; do 45 | case $type in 46 | 'fpr') # this is a new key 47 | keyfpr=$fpr 48 | uid= 49 | printedfpr=no 50 | ;; 51 | 'uid') # here comes a user id (if we don't have a key, or the 52 | # uid has no calculated validity, we will not bother 53 | # with it): 54 | if [ "$keyfpr" ] && [ "$validity" = 'f' ] ; then 55 | uid="$fpr" 56 | else 57 | uid= 58 | fi 59 | ;; 60 | 'uat') # this is a user attribute. DETAILS.gz states that the 61 | # 10th field is the number of user attribute 62 | # subpackets, followed by the total number of bytes of 63 | # the subpackets: 64 | if [ "$keyfpr" ] && [ "$validity" = 'f' ] ; then 65 | uid=$(printf "%d JPEG(?) image(s), total %d bytes" \ 66 | "${fpr%% *}" "${fpr##* }") 67 | else 68 | uid= 69 | fi 70 | ;; 71 | 'sig') # print all trust signatures, including regexes if 72 | # present, assuming that 73 | if [ "$keyfpr" ] && [ "$uid" ] ; then 74 | trustdepth=${trustparams%% *} 75 | trustlevel=${trustparams##* } 76 | if [ "$printedfpr" = no ] ; then 77 | printf "%s:\n" "$keyfpr" 78 | printedfpr=yes 79 | fi 80 | 81 | # FIXME: this is clumsy and not human-friendly. we should 82 | # print out more human-readable information, if possible. 83 | printf " :%s:%d:%d:%s\n" "$uid" "$trustdepth" "$trustlevel" "$trustdomain" 84 | fi 85 | ;; 86 | esac 87 | done 88 | 89 | } 90 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/ma/remove_certifier: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere authentication remove-certifier subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # delete a certifiers key from the host keyring 15 | 16 | remove_certifier() { 17 | 18 | local keyID 19 | local fingerprint 20 | 21 | keyID="$1" 22 | if [ -z "$keyID" ] ; then 23 | failure "You must specify the key ID of a key to remove." 24 | fi 25 | 26 | # FIXME: should we be doing a fancier list_certifier output here? 27 | gpg_core --list-key --fingerprint "0x${keyID}!" || failure 28 | 29 | if [ "$PROMPT" != "false" ] ; then 30 | printf "Really remove the above listed identity certifier? (Y/n) " >&2 31 | read OK; OK=${OK:-Y} 32 | if [ "${OK/y/Y}" != 'Y' ] ; then 33 | failure "Identity certifier not removed." 34 | fi 35 | else 36 | log debug "certifier removed without prompting." 37 | fi 38 | 39 | # delete the requested key from the sphere keyring 40 | if gpg_sphere --delete-key --batch --yes "0x${keyID}!" ; then 41 | # delete key from core keyring as well 42 | gpg_core --delete-key --batch --yes "0x${keyID}!" 43 | 44 | # update the trustdb for the authentication keyring 45 | gpg_sphere --check-trustdb 46 | 47 | log info "Identity certifier removed." 48 | else 49 | failure "Problem removing identity certifier." 50 | fi 51 | 52 | } 53 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/ma/setup: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere authentication setup subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | setup() { 15 | # make all needed directories 16 | log debug "checking authentication directory structure..." 17 | mkdir -p "${MADATADIR}" 18 | chmod 0750 "${MADATADIR}" 19 | chgrp "$MONKEYSPHERE_GROUP" "${MADATADIR}" 20 | mkdir -p "${MATMPDIR}" 21 | chmod 0750 "${MATMPDIR}" 22 | chgrp "$MONKEYSPHERE_GROUP" "${MATMPDIR}" 23 | mkdir -p "${GNUPGHOME_CORE}" 24 | chmod 0700 "${GNUPGHOME_CORE}" 25 | mkdir -p "${GNUPGHOME_SPHERE}" 26 | chmod 0700 "${GNUPGHOME_SPHERE}" 27 | mkdir -p "${SYSDATADIR}"/authorized_keys 28 | 29 | # deliberately replace the config files via truncation 30 | # FIXME: should we be dumping to tmp files and then moving atomically? 31 | log debug "writing core gpg.conf..." 32 | cat >"${GNUPGHOME_CORE}"/gpg.conf <"${GNUPGHOME_SPHERE}"/gpg.conf </dev/null | perl -MMIME::Base64 -ne 'print encode_base64($_)')) 70 | 71 | printf "generating monkeysphere authentication trust core key:\nsize: %d bits\nuid: '%s'\n" "$CORE_KEYLENGTH" "$CORE_UID" | log debug 72 | PEM2OPENPGP_USAGE_FLAGS=certify \ 73 | PEM2OPENPGP_NEWKEY=$CORE_KEYLENGTH pem2openpgp "$CORE_UID" \ 74 | | gpg_core --import \ 75 | || failure "Could not import new key for Monkeysphere authentication trust core" 76 | 77 | # get fingerprint of core key. should definitely not be empty at this point 78 | CORE_FPR=$(core_fingerprint) 79 | log debug "core fingerprint: $CORE_FPR" 80 | if [ -z "$CORE_FPR" ] ; then 81 | failure "Failed to create Monkeysphere authentication trust core!" 82 | fi 83 | 84 | else 85 | log verbose "Monkeysphere authentication trust core already exists." 86 | fi 87 | 88 | # export the core key to the sphere keyring 89 | log debug "exporting core pub key to sphere keyring..." 90 | gpg_core --export | gpg_sphere --import 91 | 92 | # ensure that the authentication sphere checker has absolute ownertrust on the expected key. 93 | log debug "setting ultimate owner trust on core key in gpg_sphere..." 94 | printf "%s:6:\n" "$CORE_FPR" | gpg_sphere --import-ownertrust 2>&1 | log verbose 95 | gpg_sphere --export-ownertrust 2>&1 | log debug 96 | 97 | # check the owner trust 98 | log debug "checking gpg_sphere owner trust set properly..." 99 | local ORIG_TRUST 100 | if ORIG_TRUST=$(gpg_sphere "--export-ownertrust" | grep '^[^#]') ; then 101 | if [ "${CORE_FPR}:6:" != "$ORIG_TRUST" ] ; then 102 | failure "Monkeysphere authentication trust sphere should explicitly trust the core. It does not have proper ownertrust settings." 103 | fi 104 | else 105 | failure "Could not get monkeysphere-authentication trust guidelines." 106 | # FIXME: what does this mean? should we suggest how to fix? 107 | fi 108 | 109 | # ensure that we're using the extended trust model (1), and that 110 | # our preferences are reasonable (i.e. 3 marginal OR 1 fully 111 | # trusted certifications are sufficient to grant full validity. 112 | log debug "checking trust model for authentication ..." 113 | local TRUST_MODEL=$(gpg_sphere "--with-colons --list-keys" 2>/dev/null \ 114 | | head -n1 | grep "^tru:" | cut -d: -f3,6,7) 115 | log debug "sphere trust model: $TRUST_MODEL" 116 | if [ "$TRUST_MODEL" != '1:3:1' ] ; then 117 | failure "monkeysphere-authentication does not have the expected trust model settings." 118 | # FIXME: what does this mean? should we suggest how to fix? 119 | fi 120 | } 121 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/ma/update_users: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere authentication update-users subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2009, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | update_users() { 15 | 16 | local returnCode=0 17 | local unames 18 | local uname 19 | local authorizedKeysDir 20 | local tmpAuthorizedKeys 21 | local authorizedUserIDs 22 | 23 | if [ "$1" ] ; then 24 | # get users from command line 25 | unames="$@" 26 | else 27 | # or just look at all users if none specified 28 | unames=$(list_users) 29 | fi 30 | 31 | # set gnupg home 32 | GNUPGHOME="$GNUPGHOME_SPHERE" 33 | 34 | # the authorized_keys directory 35 | authorizedKeysDir="${SYSDATADIR}/authorized_keys" 36 | 37 | # check to see if the gpg trust database has been initialized 38 | if [ ! -s "${GNUPGHOME}/trustdb.gpg" ] ; then 39 | failure "GNUPG trust database uninitialized. Please see MONKEYSPHERE-SERVER(8)." 40 | fi 41 | 42 | # make sure the authorized_keys directory exists 43 | mkdir -p "${authorizedKeysDir}" 44 | 45 | # loop over users 46 | for uname in $unames ; do 47 | # check all specified users exist 48 | if ! id "$uname" >/dev/null ; then 49 | log error "----- unknown user '$uname' -----" 50 | continue 51 | fi 52 | 53 | log verbose "----- user: $uname -----" 54 | 55 | # make temporary directory 56 | TMPLOC=$(mktemp -d ${MATMPDIR}/tmp.XXXXXXXXXX) || failure "Could not create temporary directory!" 57 | 58 | # trap to delete temporary directory on exit 59 | trap "rm -rf $TMPLOC" EXIT 60 | 61 | # create temporary authorized_keys file 62 | tmpAuthorizedKeys="${TMPLOC}/authorized_keys" 63 | touch "$tmpAuthorizedKeys" 64 | 65 | # set restrictive permissions on the temporary files 66 | # FIXME: is there a better way to do this? 67 | chmod 0700 "$TMPLOC" 68 | chmod 0600 "$tmpAuthorizedKeys" 69 | chown -R "$MONKEYSPHERE_USER" "$TMPLOC" 70 | 71 | # process authorized_user_ids file 72 | log debug "checking for authorized_user_ids..." 73 | # translating ssh-style path variables 74 | authorizedUserIDs=$(translate_ssh_variables "$uname" "$AUTHORIZED_USER_IDS") 75 | if [ -s "$authorizedUserIDs" ] ; then 76 | # check permissions on the authorized_user_ids file path 77 | if check_key_file_permissions "$uname" "$authorizedUserIDs" ; then 78 | log verbose "processing authorized_user_ids..." 79 | 80 | # process authorized_user_ids file, as monkeysphere user 81 | su_monkeysphere_user \ 82 | ". ${SYSSHAREDIR}/common; STRICT_MODES='$STRICT_MODES' process_authorized_user_ids -" \ 83 | < "$authorizedUserIDs" \ 84 | > "$tmpAuthorizedKeys" 85 | 86 | else 87 | log debug "not processing authorized_user_ids." 88 | fi 89 | else 90 | log debug "empty or absent authorized_user_ids file." 91 | fi 92 | 93 | # add user-controlled authorized_keys file if specified translate 94 | # ssh-style path variables 95 | rawAuthorizedKeys=$(translate_ssh_variables "$uname" "$RAW_AUTHORIZED_KEYS") 96 | if [ "$rawAuthorizedKeys" != 'none' ] ; then 97 | log debug "checking for raw authorized_keys..." 98 | if [ -s "$rawAuthorizedKeys" ] ; then 99 | # check permissions on the authorized_keys file path 100 | if check_key_file_permissions "$uname" "$rawAuthorizedKeys" ; then 101 | log verbose "adding raw authorized_keys..." 102 | 103 | cat "$rawAuthorizedKeys" >> "$tmpAuthorizedKeys" 104 | 105 | else 106 | log debug "not adding raw authorized_keys." 107 | fi 108 | else 109 | log debug "empty or absent authorized_keys file." 110 | fi 111 | fi 112 | 113 | # move the new authorized_keys file into place 114 | if [ -s "$tmpAuthorizedKeys" ] ; then 115 | # openssh appears to check the contents of the authorized_keys 116 | # file as the user in question, so the file must be readable 117 | # by that user at least. 118 | 119 | # but in general, we don't want the user tampering with this 120 | # file directly, so we'll adopt this approach: Own the file by 121 | # the monkeysphere-server invoker (usually root, but should be 122 | # the same uid that sshd is launched as); change the group of 123 | # the file so that members of the user's group can read it. 124 | 125 | if [ "$OUTPUT_STDOUT" ] ; then 126 | log debug "outputting keys to stdout..." 127 | cat "$tmpAuthorizedKeys" 128 | else 129 | log debug "moving new file to ${authorizedKeysDir}/${uname}..." 130 | # FIXME: is there a better way to do this? 131 | chown $(whoami) "$tmpAuthorizedKeys" && \ 132 | chgrp $(id -g "$uname") "$tmpAuthorizedKeys" && \ 133 | chmod g+r "$tmpAuthorizedKeys" && \ 134 | mv -f "$tmpAuthorizedKeys" "${authorizedKeysDir}/${uname}" || \ 135 | { 136 | log error "Failed to install authorized_keys for '$uname'!" 137 | rm -f "${authorizedKeysDir}/${uname}" 138 | # indicate that there has been a failure: 139 | returnCode=1 140 | } 141 | fi 142 | else 143 | rm -f "${authorizedKeysDir}/${uname}" 144 | fi 145 | 146 | # unset the trap 147 | trap - EXIT 148 | 149 | # destroy temporary directory 150 | rm -rf "$TMPLOC" 151 | done 152 | 153 | return $returnCode 154 | } 155 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/add_name: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host add-hostname subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2010, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # add servicename user ID to server key 15 | 16 | add_name() { 17 | 18 | local serviceName 19 | local keyID 20 | local fingerprint 21 | local tmpuidMatch 22 | local line 23 | local adduidCommand 24 | 25 | if [ -z "$1" ] ; then 26 | failure "You must specify a service name to add." 27 | fi 28 | serviceName="$1" 29 | shift 30 | 31 | keyID=$(check_key_input "$@") 32 | 33 | # test that the desired user ID does not already exist 34 | check_key_userid "$keyID" "$serviceName" && \ 35 | failure "Service name '$serviceName' already exists on key '$keyID'." 36 | 37 | # test that a key with that user ID does not already exist 38 | prompt_userid_exists "$serviceName" 39 | 40 | check_service_name "$serviceName" 41 | 42 | if [ "$PROMPT" != "false" ] ; then 43 | printf "The following service name will be added to key '$keyID':\n %s\nAre you sure you would like to add this service name? (Y/n) " "$serviceName" >&2 44 | read OK; OK=${OK:=Y} 45 | if [ "${OK/y/Y}" != 'Y' ] ; then 46 | failure "Service name not added." 47 | fi 48 | else 49 | log debug "adding service name without prompting." 50 | fi 51 | 52 | # execute edit-key script 53 | if PEM2OPENPGP_USAGE_FLAGS=authenticate \ 54 | <"$GNUPGHOME_HOST/secring.gpg" \ 55 | "$SYSSHAREDIR/keytrans" adduserid "$keyID" "$serviceName" \ 56 | | gpg_host --import ; then 57 | 58 | gpg_host --check-trustdb 59 | 60 | update_pgp_pub_file 61 | 62 | show_key "$keyID" 63 | 64 | echo 65 | echo "NOTE: Service name added to key, but key not published." 66 | echo "Run '$PGRM publish-key' to publish the new service name." 67 | else 68 | failure "Problem adding service name." 69 | fi 70 | 71 | } 72 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/add_revoker: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host add-revoker subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2010, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # add a revoker to the host key 15 | 16 | add_revoker() { 17 | 18 | local revokerKeyID 19 | local keyID 20 | local tmpDir 21 | local fingerprint 22 | local addrevokerCommand 23 | 24 | # check that key ID or file is specified 25 | if [ -z "$1" ] ; then 26 | failure "You must specify the key ID of a revoker key, or specify a file to read the key from." 27 | fi 28 | revokerKeyID="$1" 29 | shift 30 | 31 | keyID=$(check_key_input "$@") 32 | 33 | # make a temporary directory for storing keys during import, and set 34 | # the trap to delete it on exit 35 | tmpDir=$(msmktempdir) 36 | trap "rm -rf $tmpDir" EXIT 37 | 38 | # if file is specified 39 | if [ -f "$revokerKeyID" -o "$revokerKeyID" = '-' ] ; then 40 | # load the key from stdin 41 | if [ "$revokerKeyID" = '-' ] ; then 42 | # make a temporary file to hold the key from stdin 43 | revokerKeyID="$tmpDir"/importkey 44 | log verbose "reading revoker key from stdin..." 45 | cat > "$revokerKeyID" 46 | 47 | # load the key from the file 48 | elif [ -f "$revokerKeyID" ] ; then 49 | log verbose "reading revoker key from file '$revokerKeyID'..." 50 | fi 51 | 52 | # check the key is ok as monkeysphere user before loading 53 | log debug "checking keys in file..." 54 | fingerprint=$(su_monkeysphere_user \ 55 | ". ${SYSSHAREDIR}/common; list_primary_fingerprints" < "$revokerKeyID") 56 | 57 | if [ $(printf "%s" "$fingerprint" | egrep -c '^[A-F0-9]{40}$') -ne 1 ] ; then 58 | failure "There was not exactly one gpg key in the file." 59 | fi 60 | 61 | # load the key 62 | gpg_host --import <"$revokerKeyID" \ 63 | || failure "could not read revoker key from '$revokerKeyID'" 64 | 65 | # else, get the revoker key from the keyserver 66 | else 67 | # fix permissions and ownership on temporary directory which will 68 | # be used by monkeysphere user for storing the downloaded key 69 | chmod 0700 "$tmpDir" 70 | chown "$MONKEYSPHERE_USER":"$MONKEYSPHERE_GROUP" "$tmpDir" 71 | 72 | # download the key from the keyserver as the monkeysphere user 73 | log verbose "searching keyserver $KEYSERVER for revoker keyID $revokerKeyID..." 74 | su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --quiet --keyserver $KEYSERVER --recv-key 0x${revokerKeyID}!" \ 75 | || failure "Could not receive a key with this ID from keyserver '$KEYSERVER'." 76 | 77 | # get the full fingerprint of new revoker key 78 | log debug "getting fingerprint of revoker key..." 79 | fingerprint=$(su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --list-key --with-colons --with-fingerprint ${revokerKeyID}" \ 80 | | grep '^fpr:' | cut -d: -f10) 81 | 82 | # test that there is only a single fingerprint 83 | if (( $(echo "$fingerprint" | wc -l) != 1 )) ; then 84 | cat <&2 97 | read OK; OK=${OK:-Y} 98 | if [ "${OK/y/Y}" != 'Y' ] ; then 99 | failure "revoker not added." 100 | fi 101 | else 102 | log debug "adding revoker without prompting." 103 | fi 104 | 105 | # export the new key to the host keyring 106 | log debug "loading revoker key into host keyring..." 107 | su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --quiet --export 0x${fingerprint}!" \ 108 | | gpg_host --import 109 | fi 110 | 111 | # edit-key script to add revoker 112 | addrevokerCommand="addrevoker 113 | $fingerprint 114 | y 115 | save 116 | " 117 | # end script 118 | 119 | # core ltsigns the newly imported revoker key 120 | log debug "executing add revoker script..." 121 | if echo "$addrevokerCommand" | gpg_host_edit "0x${keyID}!" ; then 122 | 123 | update_pgp_pub_file 124 | 125 | log info "Revoker added." 126 | else 127 | failure "Problem adding revoker." 128 | fi 129 | 130 | # remove the temporary directory 131 | trap - EXIT 132 | rm -rf "$tmpDir" 133 | 134 | } 135 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/diagnostics: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host diagnostics subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2010, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # check on the status and validity of the host's public certificates (and keys?) 15 | 16 | # global vars for communicating between functions: 17 | 18 | MHD_CURDATE=$(date +%s) 19 | # warn when anything is 2 months away from expiration 20 | MHD_WARNWINDOW='2 months' 21 | MHD_WARNDATE=$(advance_date $MHD_WARNWINDOW +%s) 22 | MHD_PROBLEMSFOUND=0 23 | 24 | 25 | diagnose_key() { 26 | local fpr="$1" 27 | local certinfo 28 | local create 29 | local expire 30 | local uid 31 | local keysfound 32 | local uiderrs 33 | local errcount 34 | 35 | printf "Checking OpenPGP Certificate for key 0x%s\n" "$fpr" 36 | 37 | certinfo=$(get_cert_info "0x$fpr" <"$HOST_KEY_FILE") 38 | keysfound=$(grep -c ^pub: <<<"$certinfo") 39 | 40 | if [ "$keysfound" -lt 1 ] ; then 41 | printf "! Could not find key with fingerprint 0x%s\n" "$fpr" 42 | # FIXME: recommend a way to resolve this! 43 | MHD_PROBLEMSFOUND=$(($MHD_PROBLEMSFOUND+1)) 44 | fi 45 | 46 | create=$(echo "$certinfo" | grep ^pub: | cut -f6 -d:) 47 | expire=$(echo "$certinfo" | grep ^pub: | cut -f7 -d:) 48 | # check for key expiration: 49 | if [ "$expire" ]; then 50 | if (( "$expire" < "$MHD_CURDATE" )); then 51 | printf "! Host key 0x%s is expired.\n" "$fpr" 52 | printf " - Recommendation: extend lifetime of key with 'monkeysphere-host set-expire 0x%s'\n" "$fpr" 53 | MHD_PROBLEMSFOUND=$(($MHD_PROBLEMSFOUND+1)) 54 | elif (( "$expire" < "$MHD_WARNDATE" )); then 55 | printf "! Host key 0x%s expires in less than %s: %s\n" "$fpr" "$MHD_WARNWINDOW" $(advance_date $(( $expire - $MHD_CURDATE )) seconds +%F) 56 | printf " - Recommendation: extend lifetime of key with 'monkeysphere-host set-expire %s'\n" "$fpr" 57 | MHD_PROBLEMSFOUND=$(($MHD_PROBLEMSFOUND+1)) 58 | fi 59 | fi 60 | 61 | # and weirdnesses: 62 | if [ "$create" ] && (( "$create" > "$MHD_CURDATE" )); then 63 | printf "! Host key 0x%s was created in the future(?!): %s. Is your clock correct?\n" "$fpr" $(date -d "1970-01-01 + $create seconds" +%F) 64 | printf " - Recommendation: Check your clock (is it really %s?); use NTP?\n" $(date +%F_%T) 65 | MHD_PROBLEMSFOUND=$(($MHD_PROBLEMSFOUND+1)) 66 | fi 67 | 68 | # check for UserID expiration: 69 | uiderrs=$(printf '%s\n' "$certinfo" | grep ^uid: | cut -d: -f6,7,10 | \ 70 | while IFS=: read -r create expire uid ; do 71 | uid=$(gpg_unescape <<<"$uid") 72 | 73 | check_service_name "$uid" 74 | if [ "$create" ] && (( "$create" > "$MHD_CURDATE" )); then 75 | printf "! The latest self-sig on User ID '%s' was created in the future(?!): %s.\n - Is your clock correct?\n" "$uid" $(date -d "1970-01-01 + $create seconds" +%F) 76 | printf " - Recommendation: Check your clock (is it really %s ?); use NTP?\n" $(date +%F_%T) 77 | fi 78 | if [ "$expire" ] ; then 79 | if (( "$expire" < "$MHD_CURDATE" )); then 80 | printf "! User ID '%s' is expired.\n" "$uid" 81 | # FIXME: recommend a way to resolve this 82 | elif (( "$expire" < "$MHD_WARNDATE" )); then 83 | printf "! User ID '%s' expires in less than %s: %s\n" "%s" "$MHD_WARNWINDOW" $(advance_date $(( $expire - $MHD_CURDATE )) seconds +%F) 84 | # FIXME: recommend a way to resolve this 85 | fi 86 | fi 87 | done) 88 | errcount=$(grep -c '^!' <<<"$uiderrs") || \ 89 | MHD_PROBLEMSFOUND=$(($MHD_PROBLEMSFOUND+ $errcount )) 90 | printf '%s\n' "$uiderrs" 91 | 92 | 93 | 94 | # FIXME: verify that the host key is properly published to the 95 | # keyservers (do this with the non-privileged user) 96 | 97 | # FIXME: check that there are valid, non-expired certifying signatures 98 | # attached to the host key after fetching from the public keyserver 99 | # (do this with the non-privileged user as well) 100 | 101 | # FIXME: propose adding a revoker to the host key if none exist (do we 102 | # have a way to do that after key generation?) 103 | 104 | # FIXME: test (with ssh-keyscan?) that any running ssh daemon is 105 | # actually offering the monkeysphere host key, if such a key is 106 | # loaded. 107 | 108 | # FIXME: scan /proc/net/tcp and /proc/net/tcp6 to see what 109 | # known-crypto ports (ssh, https, imaps?, ldaps?, etc) are in use 110 | # locally. Propose bringing them into the monkeysphere. 111 | 112 | # FIXME: ensure that the key is of a reasonable size 113 | 114 | # FIXME: ensure that the cert has the right key usage flags 115 | 116 | # FIXME: ensure that the key doesn't match any known blacklist 117 | } 118 | 119 | diagnostics() { 120 | 121 | MHD_PROBLEMSFOUND=0 122 | 123 | 124 | if ! [ -d "$SYSDATADIR" ] ; then 125 | echo "! no $SYSDATADIR directory found. Please create it." 126 | exit 127 | fi 128 | 129 | if ! [ -f "$HOST_KEY_FILE" ] ; then 130 | echo "No host OpenPGP certificates file found!" 131 | echo " - Recommendation: run 'monkeysphere-host import-key' with a service key" 132 | exit 133 | fi 134 | 135 | if ! id monkeysphere >/dev/null ; then 136 | echo "! No monkeysphere user found! Please create a monkeysphere system user with bash as its shell." 137 | MHD_PROBLEMSFOUND=$(($MHD_PROBLEMSFOUND+1)) 138 | fi 139 | 140 | echo "Checking host OpenPGP certificates..." 141 | multi_key diagnose_key 142 | 143 | # FIXME: look at the ownership/privileges of the various keyrings, 144 | # directories housing them, etc (what should those values be? can 145 | # we make them as minimal as possible?) 146 | 147 | # report on any cruft from old monkeysphere version 148 | report_cruft 149 | 150 | if [ "$MHD_PROBLEMSFOUND" -gt 0 ]; then 151 | echo "When the above $MHD_PROBLEMSFOUND issue"$(if [ "$MHD_PROBLEMSFOUND" -eq 1 ] ; then echo " is" ; else echo "s are" ; fi)" resolved, please re-run:" 152 | echo " monkeysphere-host diagnostics" 153 | else 154 | echo "Everything seems to be in order!" 155 | fi 156 | 157 | } 158 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/import_key: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host import-key subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2010 and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | import_key() { 15 | 16 | local keyFile="$1" 17 | local serviceName="$2" 18 | 19 | # check that key file specified 20 | if [ -z "$keyFile" ] ; then 21 | failure "Must specify PEM-encoded key file to import, or specify '-' for stdin." 22 | fi 23 | 24 | # fail if hostname not specified 25 | if [ -z "$serviceName" ] ; then 26 | failure "You must specify a service name for use in the OpenPGP certificate user ID." 27 | fi 28 | 29 | # test that a key with that user ID does not already exist 30 | prompt_userid_exists "$serviceName" 31 | 32 | # check that the service name is well formatted 33 | check_service_name "$serviceName" 34 | 35 | # create host home 36 | mkdir -p "${MHDATADIR}" 37 | mkdir -p "${GNUPGHOME_HOST}" 38 | chmod 700 "${GNUPGHOME_HOST}" 39 | 40 | # import pem-encoded key to an OpenPGP private key 41 | if [ "$keyFile" = '-' ] ; then 42 | log verbose "importing key from stdin..." 43 | PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$serviceName" \ 44 | | gpg_host --import 45 | else 46 | log verbose "importing key from file '$keyFile'..." 47 | PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$serviceName" \ 48 | <"$keyFile" \ 49 | | gpg_host --import 50 | fi 51 | 52 | # export to OpenPGP public key to file 53 | update_pgp_pub_file 54 | 55 | log info "host key imported:" 56 | 57 | # show info about new key 58 | show_key "$serviceName" 59 | 60 | } 61 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/publish_key: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host publish-key subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2010, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # publish keys to keyserver 15 | 16 | publish_key() { 17 | 18 | local keyID="$1" 19 | local GNUPGHOME 20 | 21 | if [ "$PROMPT" != "false" ] ; then 22 | log debug "Because \$MONKEYSPHERE_PROMPT is set to $PROMPT, interactively confirm publishing key" 23 | printf "Really publish key '$keyID' to $KEYSERVER? (Y/n) " >&2 24 | read OK; OK=${OK:=Y} 25 | if [ "${OK/y/Y}" != 'Y' ] ; then 26 | log error "key not published." 27 | return 28 | fi 29 | else 30 | log debug "publishing key '$keyID' without prompting." 31 | fi 32 | 33 | # create a temporary gnupg directory from which to publish the key 34 | export GNUPGHOME=$(msmktempdir) 35 | chmod 0700 "$GNUPGHOME" 36 | chown "$MONKEYSPHERE_USER":"$MONKEYSPHERE_GROUP" "$GNUPGHOME" 37 | 38 | # trap to remove tmp dir if break 39 | trap "rm -rf $GNUPGHOME" EXIT 40 | 41 | # import the key into the tmp dir 42 | su_monkeysphere_user \ 43 | "gpg --quiet --import" <"$HOST_KEY_FILE" 44 | 45 | KEYSERVER_OPTIONS="" 46 | for anchorfile in "${SYSCONFIGDIR}/monkeysphere-host-x509-anchors.crt" "${SYSCONFIGDIR}/monkeysphere-x509-anchors.crt"; do 47 | if [ -z "$KEYSERVER_OPTIONS" ] && [ -r "$anchorfile" ] ; then 48 | log debug "using trust anchor file: $anchorfile" 49 | KEYSERVER_OPTIONS="--keyserver-options 'ca-cert-file=$anchorfile'" 50 | fi 51 | done 52 | 53 | # publish key 54 | log debug "publishing key with the following gpg command line and options:" 55 | su_monkeysphere_user \ 56 | "gpg --keyserver $KEYSERVER $KEYSERVER_OPTIONS --send-keys '0x${keyID}!'" 57 | 58 | # remove the tmp file 59 | trap - EXIT 60 | rm -rf "$GNUPGHOME" 61 | 62 | } 63 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/revoke_key: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host revoke-key subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2010, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # revoke host key 15 | 16 | revoke_key() { 17 | 18 | local keyID 19 | local publish 20 | 21 | keyID=$(check_key_input "$@") 22 | 23 | if [ "$PROMPT" = "false" ] ; then 24 | publish=N 25 | else 26 | cat <&2 27 | This will generate a revocation certificate for key $keyID 28 | and dump the certificate to standard output. 29 | 30 | It can also directly publish the new revocation certificate 31 | to the public keyservers via $KEYSERVER if you want it to. 32 | 33 | Publishing this certificate will IMMEDIATELY and PERMANENTLY revoke 34 | your host key! 35 | 36 | EOF 37 | printf "Publish the certificate after generation? (y/n/Q) " >&2 38 | read publish 39 | 40 | if ! [ "${publish/y/Y}" = 'Y' -o "${publish/n/N}" = 'N' ] ; then 41 | failure "aborting at user request" 42 | fi 43 | fi 44 | 45 | # our current implementation is very simple: we just want to 46 | # generate the revocation certificate on stdout. This provides 47 | # for the two most likely (but hopefully not common) scenarios: 48 | 49 | # an admin wants a revocation certificate for the host which they 50 | # can store securely offline. In this case, the admin can 51 | # redirect stdout to a file, or can simply copy/paste or 52 | # transcribe from the terminal. 53 | 54 | # Alternately, an admin might want to publish the revocation 55 | # certificate immediately, which we can help them do as well. 56 | 57 | if [ "$PROMPT" = 'false' ] ; then 58 | # FIXME: allow the end user to choose something other than 59 | # "key was compromised" (1) and to supply their own revocation 60 | # string. 61 | 62 | local revoke_commands="y 63 | 1 64 | Monkeysphere host key revocation (automated) $(date '+%F_%T%z') 65 | 66 | y 67 | 68 | " 69 | revcert=$(GNUPGHOME="$GNUPGHOME_HOST" gpg_host --command-fd 0 --armor --gen-revoke "0x${keyID}!" <<<"$revoke_commands" ) \ 70 | || failure "Failed to generate revocation certificate!" 71 | 72 | else 73 | # note: we're not using the gpg_host function because we actually 74 | # want to use gpg's UI in this case, so we want to omit --no-tty 75 | revcert=$(GNUPGHOME="$GNUPGHOME_HOST" gpg --no-greeting --quiet --armor --gen-revoke "0x${keyID}!") \ 76 | || failure "Failed to generate revocation certificate!" 77 | fi 78 | 79 | # if you run gpg --gen-revoke but cancel it or quit in the middle, 80 | # it returns success, but emits no revocation certificate: 81 | if ! [ "$revcert" ] ; then 82 | failure "Revocation canceled." 83 | fi 84 | 85 | ## ok, now we have the revocation certificate. Print it, and 86 | ## offer to publish if originally requested: 87 | printf "%s\n" "$revcert" 88 | 89 | if [ "${publish/y/Y}" = 'Y' ] ; then 90 | printf "\n" >&2 91 | printf "Really publish this cert to $KEYSERVER ? (Y/n) " >&2 92 | read really 93 | if [ "${really/n/N}" = 'N' ] ; then 94 | printf "Not publishing.\n" >&2 95 | else 96 | local newhome=$(msmktempdir) 97 | GNUPGHOME="$newhome" gpg --no-tty --quiet --import < "$HOST_KEY_FILE" 98 | GNUPGHOME="$newhome" gpg --no-tty --quiet --import <<< "$revcert" 99 | GNUPGHOME="$newhome" gpg --keyserver "$KEYSERVER" --send "0x${keyID}!" 100 | rm -rf "$newhome" 101 | fi 102 | fi 103 | } 104 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/revoke_name: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host revoke-hostname subcommand 5 | # 6 | # The monkeysphere scripts are written by: 7 | # Jameson Rollins 8 | # Jamie McClelland 9 | # Daniel Kahn Gillmor 10 | # 11 | # They are Copyright 2008-2010, and are all released under the GPL, 12 | # version 3 or later. 13 | 14 | # revoke service name user ID from host key 15 | 16 | revoke_name() { 17 | 18 | local serviceName 19 | local keyID 20 | local fingerprint 21 | local tmpuidMatch 22 | local line 23 | local message 24 | local revuidCommand 25 | 26 | if [ -z "$1" ] ; then 27 | failure "You must specify a service name to revoke." 28 | fi 29 | serviceName="$1" 30 | shift 31 | 32 | keyID=$(check_key_input "$@") 33 | 34 | # make sure the user ID to revoke exists 35 | check_key_userid "$keyID" "$serviceName" || \ 36 | failure "No non-revoked service name found matching '$serviceName'." 37 | 38 | if [ "$PROMPT" != "false" ] ; then 39 | printf "The following service name on key '$keyID' will be revoked:\n %s\nAre you sure you would like to revoke this service name? (Y/n) " "$serviceName" >&2 40 | read OK; OK=${OK:=Y} 41 | if [ "${OK/y/Y}" != 'Y' ] ; then 42 | failure "User ID not revoked." 43 | fi 44 | else 45 | log debug "revoking service name without prompting." 46 | fi 47 | 48 | # actually revoke: 49 | 50 | # the gpg secring might not contain the host key we are trying to 51 | # revoke (let alone any selfsig over that host key), but the plain 52 | # --export won't contain the secret key. "keytrans revokeuserid" 53 | # needs access to both pieces, so we feed it both of them. 54 | 55 | if (cat "$GNUPGHOME_HOST/secring.gpg" && gpg_host --export "$keyID") \ 56 | | "$SYSSHAREDIR/keytrans" revokeuserid "$keyID" "$serviceName" \ 57 | | gpg_host --import ; then 58 | 59 | gpg_host --check-trustdb 60 | 61 | update_pgp_pub_file 62 | 63 | show_key "$keyID" 64 | 65 | echo 66 | echo "NOTE: Service name revoked, but revocation not published." 67 | echo "Run '$PGRM publish-key' to publish the revocation." 68 | else 69 | failure "Problem revoking service name." 70 | fi 71 | 72 | } 73 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/share/mh/set_expire: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) 3 | 4 | # Monkeysphere host set-expire subcommand 5 | # 6 | # This is a function to set the expiration date of the monkeysphere 7 | # host key. 8 | # 9 | # The monkeysphere scripts are written by: 10 | # Jameson Rollins 11 | # Jamie McClelland 12 | # Daniel Kahn Gillmor 13 | # 14 | # They are Copyright 2008-2010, and are all released under the GPL, 15 | # version 3 or later. 16 | 17 | set_expire() { 18 | 19 | local extendBy 20 | local keyID 21 | 22 | local formatMsg=' 23 | The possibilities are: 24 | 0 = key does not expire 25 | = key expires in n days 26 | w = key expires in n weeks 27 | m = key expires in n months 28 | y = key expires in n years' 29 | 30 | 31 | if [ -z "$1" ] ; then 32 | failure "Must specify expiration.$formatMsg" 33 | fi 34 | extendBy="$1" 35 | shift 36 | 37 | if ! <<<"$extendBy" egrep -q '^[[:digit:]]+[wmy]?$' ; then 38 | failure "'$extendBy' is not a valid expiration date.$formatMsg" 39 | fi 40 | 41 | keyID=$(check_key_input "$@") 42 | 43 | if [ "$PROMPT" != "false" ] ; then 44 | printf "Are you sure you want to change the expiration on key '$keyID' by '%s'? (Y/n) " "$extendBy" >&2 45 | read OK; OK=${OK:-Y} 46 | if [ "${OK/y/Y}" != 'Y' ] ; then 47 | failure "expiration not set." 48 | fi 49 | else 50 | log debug "extending without prompting." 51 | fi 52 | 53 | log info "setting key expiration to ${extendBy}." 54 | 55 | log debug "executing key expire script..." 56 | gpg_host_edit "0x${keyID}!" expire <=0.23) setup. 5 | 6 | # You should be able to run this script after any version >= 0.23 is 7 | # installed. This script should be well-behaved, even if it is run 8 | # repeatedly. 9 | 10 | # Written by 11 | # Jameson Rollins 12 | # Daniel Kahn Gillmor 13 | # 14 | # Copyright 2009, released under the GPL, version 3 or later 15 | 16 | # NOTE: the reverse operation (downgrading) is not directly supported, 17 | # and MAY LOCK YOU OUT OF YOUR SYSTEM, depending on how you have 18 | # configured the monkeysphere! 19 | 20 | # any unexpected errors should cause this script to bail: 21 | set -e 22 | 23 | SYSSHAREDIR=${MONKEYSPHERE_SYSSHAREDIR:-"__SYSSHAREDIR_PREFIX__/share/monkeysphere"} 24 | export SYSSHAREDIR 25 | . "${SYSSHAREDIR}/defaultenv" 26 | 27 | MADATADIR="${SYSDATADIR}/authentication" 28 | MHDATADIR="${SYSDATADIR}/host" 29 | 30 | STASHDIR="${SYSDATADIR}/backup-from-0.23-transition" 31 | 32 | 33 | log() { 34 | printf "$@" >&2 35 | } 36 | 37 | # FIXME: implement this function better. here, we only care about 38 | # dots, *and* about reversing the regexification of them. 39 | gpg_unescape_and_unregex() { 40 | sed 's/\\x5c\././g' 41 | } 42 | 43 | 44 | is_domain_name() { 45 | printf "%s" "$1" | egrep -q '^[[:alnum:]][[:alnum:]-.]*[[:alnum:]]$' 46 | } 47 | 48 | 49 | # move the old server conf file to be the authentication conf file 50 | if [ -f "$SYSCONFIGDIR"/monkeysphere-server.conf -a \ 51 | ! -f "$SYSCONFIGDIR"/monkeysphere-authentication.conf ] ; then 52 | mv "$SYSCONFIGDIR"/monkeysphere-server.conf "$SYSCONFIGDIR"/monkeysphere-authentication.conf 53 | fi 54 | 55 | # run the authentication setup (this is also the first chance to bail 56 | # if 0.23 is not fully-installed, because m-a did not exist before 57 | # 0.23) 58 | monkeysphere-authentication setup 59 | 60 | # before 0.23, the old gnupg-host data directory used to contain the 61 | # trust core and the system's ssh host key. 62 | 63 | if [ -d "$SYSDATADIR"/gnupg-host ] ; then 64 | 65 | ### transfer identity certifiers, if they don't already exist in the 66 | ### current setup: 67 | 68 | if monkeysphere-authentication list-identity-certifiers | \ 69 | grep -q '^[A-F0-9]{40}:$' ; then 70 | log 'There are already certifiers in the new system!\nNot transferring any certifiers.\n' 71 | else 72 | # get the old host keygrip (don't know why there would be more 73 | # than one, but we'll transfer all tsigs made by any key that 74 | # had been given ultimate ownertrust): 75 | for authgrip in $(GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --quiet --no-tty --no-permission-warning --export-ownertrust | \ 76 | grep ':6:$' | \ 77 | sed -r 's/^[A-F0-9]{24}([A-F0-9]{16}):6:$/\1/') ; do 78 | 79 | # we're assuming that old id certifiers were only added by old 80 | # versions of m-s c+, which added certifiers by ltsigning 81 | # entire keys. 82 | 83 | # so we'll walk the list of tsigs from the old host key, and 84 | # add those keys as certifiers to the new system. 85 | 86 | # FIXME: if an admin has run "m-s add-id-certifier $foo" 87 | # multiple times for the same $foo, we'll only transfer 88 | # one of those certifications (even if later 89 | # certifications had different parameters). 90 | 91 | GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --quiet --no-tty --no-permission-warning --fingerprint --with-colons --fixed-list-mode --check-sigs | \ 92 | cut -f 1,2,5,8,9,10 -d: | \ 93 | egrep '^(fpr:::::|sig:!:'"$authgrip"':[[:digit:]]+ [[:digit:]]+:)' | \ 94 | while IFS=: read -r type validity grip trustparams trustdomain fpr ; do 95 | case $type in 96 | 'fpr') # this is a new key 97 | keyfpr=$fpr 98 | ;; 99 | 'sig') # deal with all trust signatures, including 100 | # regexes if present. 101 | if [ "$keyfpr" ] ; then 102 | trustdepth=${trustparams%% *} 103 | trustlevel=${trustparams##* } 104 | if [ "$trustlevel" -ge 120 ] ; then 105 | truststring=full 106 | elif [ "$trustlevel" -ge 60 ] ; then 107 | truststring=marginal 108 | else 109 | # trust levels below marginal are ignored. 110 | continue 111 | fi 112 | 113 | finaldomain= 114 | if [ "$trustdomain" ] ; then 115 | # FIXME: deal with translating 116 | # $trustdomain back to a domain. 117 | if [ printf "%s" "$trustdomain" | egrep -q '^<\[\^>\]\+\[@\.\][^>]+>\$$' ] ; then 118 | dpart=$(printf "%s" "$trustdomain" | sed -r 's/^<\[\^>\]\+\[@\.\]([^>]+)>\$$/\1/' | gpg_unescape_and_unregex) 119 | if [ is_domain_name "$dpart" ]; then 120 | finaldomain="--domain $dpart" 121 | else 122 | log "Does not seem to be a domain name (%s), not adding certifier\n" "$dpart" 123 | continue 124 | fi 125 | else 126 | log "Does not seem to be a standard gpg domain-based tsig (%s), not adding certifier\n" "$trustdomain" 127 | continue 128 | fi 129 | fi 130 | 131 | CERTKEY=$(mktemp ${TMPDIR:-/tmp}/mstransition.XXXXXXXX) 132 | log "Adding identity certifier with fingerprint %s\n" "$keyfpr" 133 | GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --quiet --no-tty --no-permission-warning --export "0x$keyfpr" --export-options export-clean >"$CERTKEY" 134 | MONKEYSPHERE_PROMPT=false monkeysphere-authentication add-identity-certifier $finaldomain --trust "$truststring" --depth "$trustdepth" "$CERTKEY" 135 | rm -f "$CERTKEY" 136 | # clear the fingerprint so that we don't 137 | # make additional tsigs on it if more uids 138 | # are present: 139 | keyfpr= 140 | fi 141 | ;; 142 | esac 143 | done 144 | done 145 | fi 146 | 147 | ### transfer host key information (if present) into the new spot 148 | 149 | if [ -d "${MHDATADIR}" ] ; then 150 | log "Not transferring host key info because host directory already exists.\n" 151 | else 152 | if [ -s "$SYSDATADIR"/ssh_host_rsa_key ] || \ 153 | GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --quiet --no-tty --no-permission-warning --with-colons --list-secret-keys | grep -q '^sec:' ; then 154 | 155 | FPR=$(GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --quiet --no-tty --no-permission-warning --with-colons --fixed-list-mode --list-secret-keys --fingerprint | awk -F: '/^fpr:/{ print $10 }' ) 156 | 157 | # create host home 158 | mkdir -p $(dirname "$MHDATADIR") 159 | NEWDATADIR=$(mktemp -d "${MHDATADIR}.XXXXXX") 160 | chmod 0700 "${NEWDATADIR}" 161 | 162 | log "importing host key from old monkeysphere installation\n" 163 | 164 | # export from the pubring as well as the that new (non-expired) 165 | # self-sigs are available, otherwise the secret key import may fail 166 | 167 | # FIXME: turns out the secret key import fails anyway, stupidly :( 168 | 169 | # FIXME: if all self-sigs are expired, then the secret key import may 170 | # fail anyway. How should we deal with that? 171 | 172 | if (GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --quiet --no-tty --no-permission-warning --export-secret-keys && \ 173 | GNUPGHOME="$SYSDATADIR"/gnupg-host gpg --quiet --no-tty --no-permission-warning --export "$FPR") | \ 174 | GNUPGHOME="$NEWDATADIR" gpg --quiet --no-tty --import ; then 175 | : we are in good shape! 176 | else 177 | if ! GNUPGHOME="$NEWDATADIR" gpg --quiet --no-tty --list-secret-key >/dev/null ; then 178 | log "The old host key (%s) was not imported properly.\n" "$FPR" 179 | exit 1 180 | fi 181 | fi 182 | 183 | # if we get here cleanly, then we're OK to move forward: 184 | mv "$NEWDATADIR" "$MHDATADIR" 185 | 186 | monkeysphere-host update-gpg-pub-file 187 | else 188 | log "No host key found in old monkeysphere install; not importing any host key.\n" 189 | fi 190 | fi 191 | 192 | 193 | ### get rid of this old stuff, since we've transferred it all: 194 | 195 | mkdir -p "$STASHDIR" 196 | chmod 0700 "$STASHDIR" 197 | mv "${SYSDATADIR}/gnupg-host" "$STASHDIR"/gnupg-host.$(date '+%F_%T%z') 198 | fi 199 | 200 | 201 | # There is nothing in the old authentication directory that we should 202 | # need to keep around, but it is not unreasonable to transfer keys to 203 | # the new authentication keyring. 204 | if [ -d "${SYSDATADIR}/gnupg-authentication" ] ; then 205 | 206 | GNUPGHOME="${SYSDATADIR}/gnupg-authentication" \ 207 | gpg --quiet --no-tty --no-permission-warning --export 2>/dev/null | \ 208 | monkeysphere-authentication gpg-cmd --import 2>/dev/null || \ 209 | log "No OpenPGP certificates imported into monkeysphere-authentication trust sphere.\n" 210 | 211 | mkdir -p "$STASHDIR" 212 | chmod 0700 "$STASHDIR" 213 | mv "${SYSDATADIR}/gnupg-authentication" "$STASHDIR"/gnupg-authentication.$(date '+%F_%T%z') 214 | fi 215 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/transitions/0.28: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This is a post-install script for monkeysphere, to transition an old 4 | # (<0.28) setup to the new (>=0.28) setup. 5 | 6 | # You should be able to run this script after any version >= 0.23 is 7 | # installed. This script should be well-behaved, even if it is run 8 | # repeatedly. 9 | 10 | # Written by 11 | # Jameson Rollins 12 | # Daniel Kahn Gillmor 13 | # 14 | # Copyright 2010, released under the GPL, version 3 or later 15 | 16 | # any unexpected errors should cause this script to bail: 17 | set -e 18 | 19 | SYSSHAREDIR=${MONKEYSPHERE_SYSSHAREDIR:-"__SYSSHAREDIR_PREFIX__/share/monkeysphere"} 20 | export SYSSHAREDIR 21 | . "${SYSSHAREDIR}/defaultenv" 22 | 23 | 24 | OLD_HOST_KEY_FILE="$SYSDATADIR"/ssh_host_rsa_key.pub.gpg 25 | if [ -f "$OLD_HOST_KEY_FILE" ] ; then 26 | monkeysphere-host update-pgp-pub-file 27 | rm -f "$OLD_HOST_KEY_FILE" 28 | fi 29 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/src/transitions/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains transition scripts for major changes to 2 | monkeysphere infrastructure. 3 | 4 | They are expected to be run immediately after upgrading to the named 5 | version or later. 6 | 7 | For example: you upgrade to from version 0.8 to version 0.15, and the 8 | directory contains 0.6, 0.12 and 0.15, you should run 0.12 followed by 9 | 0.15. 10 | 11 | The scripts are supposed to be cleverly-written enough that you can 12 | run them repeatedly, and they should only make their intended changes 13 | once. If they do not behave that way, this is a bug. Please report 14 | it! 15 | 16 | https://labs.riseup.net/code/projects/monkeysphere/ 17 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/README: -------------------------------------------------------------------------------- 1 | Monkeysphere test infrastructure 2 | ================================ 3 | 4 | These are scripts to test various aspects of the Monkeysphere system. 5 | 6 | Some notes about getting started working on the monkeysphere test 7 | infrastructure: 8 | 9 | - the tests can and should be run as a non-privileged user. since the 10 | tests do potentially destructive things (like wiping out and 11 | recreating gpg keyrings) they should definitely *not* be run as 12 | root. it may even be advisable to run them as a different, 13 | dedicated user, so that any goofs you make while updating the test 14 | infrastructure don't compromise your main account. 15 | 16 | - you do not need the monkeysphere package installed locally, though 17 | you will need the monkeysphere dependencies installed locally. 18 | 19 | - the idea with this script is to do the following: 20 | 21 | - set up test server infrastructure 22 | - test the server setup 23 | - set up test user 24 | - test an ssh connection between test user and test server 25 | - modify server/user setup and rerun ssh_test to make sure it 26 | suceeds/fails as expected 27 | 28 | - there are various FIXMEs in the script that outline some of the 29 | further testing that should be undertaken. 30 | 31 | - good documentation in the code in the form of comments are needed. 32 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/common: -------------------------------------------------------------------------------- 1 | # -*-shell-script-*- 2 | 3 | failed_cleanup() { 4 | # FIXME: can we be more verbose here? 5 | echo 'FAILED!' 6 | if [ -z "$MONKEYSPHERE_TEST_NO_EXAMINE" ] ; then 7 | printf "press enter to cleanup and remove tmp (or type 'bash' for a subshell to examine): " >&2 8 | read XX 9 | if [ "$XX" = bash ] ; then 10 | echo "Entering subshell..." 11 | cd "$TEMPDIR" 12 | bash 13 | fi 14 | fi 15 | 16 | cleanup 17 | } 18 | 19 | get_gpg_prng_arg() { 20 | if (gpg --quick-random --version >/dev/null 2>&1) ; then 21 | echo quick-random 22 | elif (gpg --debug-quick-random --version >/dev/null 2>&1) ; then 23 | echo debug-quick-random 24 | fi 25 | } 26 | 27 | cleanup() { 28 | echo "### removing temp dir..." 29 | rm -rf "$TEMPDIR" 30 | 31 | if [ "$SSHD_PID" ] ; then 32 | echo "### killing off lingering sshd..." 33 | kill "$SSHD_PID" 34 | fi 35 | 36 | wait 37 | } 38 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/etc/monkeysphere/monkeysphere-authentication.conf: -------------------------------------------------------------------------------- 1 | # Base monkeysphere-authentication.conf for monkeysphere tests 2 | 3 | # AUTHORIZED_USER_IDS variable will be added dynamically during test. 4 | 5 | RAW_AUTHORIZED_KEYS=none 6 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/etc/ssh/sshd_config: -------------------------------------------------------------------------------- 1 | # Base sshd_config for monkeysphere test 2 | 3 | # HostKey and AuthorizedKeysFile lines will be added dynamically 4 | # during test. 5 | 6 | # goal: minimal ssh configuration to do public key authentication. 7 | 8 | Protocol 2 9 | PubkeyAuthentication yes 10 | HostbasedAuthentication no 11 | PermitEmptyPasswords no 12 | ChallengeResponseAuthentication no 13 | PasswordAuthentication no 14 | KerberosAuthentication no 15 | GSSAPIAuthentication no 16 | X11Forwarding no 17 | PrintMotd no 18 | PrintLastLog no 19 | TCPKeepAlive no 20 | AcceptEnv LANG LC_* 21 | UsePAM no 22 | UsePrivilegeSeparation no 23 | LogLevel DEBUG 24 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/admin/.gnupg/pubkey.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/admin/.gnupg/pubkey.gpg -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/admin/.gnupg/pubring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/admin/.gnupg/pubring.gpg -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/admin/.gnupg/random_seed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/admin/.gnupg/random_seed -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/admin/.gnupg/secring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/admin/.gnupg/secring.gpg -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/admin/.gnupg/trustdb.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/admin/.gnupg/trustdb.gpg -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.gnupg/gpg.conf: -------------------------------------------------------------------------------- 1 | # other options 2 | verify-options show-uid-validity 3 | list-options show-uid-validity 4 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.gnupg/pubring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/testuser/.gnupg/pubring.gpg -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.gnupg/random_seed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/testuser/.gnupg/random_seed -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.gnupg/secring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/testuser/.gnupg/secring.gpg -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.gnupg/trustdb.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/lib/monkeysphere-0.35/tests/home/testuser/.gnupg/trustdb.gpg -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.monkeysphere/authorized_user_ids: -------------------------------------------------------------------------------- 1 | Monkeysphere Test Suite Test User (DO NOT USE!!!) 2 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.monkeysphere/monkeysphere.conf: -------------------------------------------------------------------------------- 1 | # monkeysphere config for testuser in monkeysphere test suite 2 | 3 | LOG_LEVEL=DEBUG 4 | 5 | # KNOWN_HOSTS will be dynamically defined after creation. 6 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.ssh/askpass: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # phony/automatic askpass, to provide the passphrase for the 4 | # testuser's GPG key. 5 | 6 | echo abc123 7 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.ssh/config: -------------------------------------------------------------------------------- 1 | # ssh config file for testuser for monkeysphere test suite. 2 | Host * 3 | ChallengeResponseAuthentication no 4 | PasswordAuthentication no 5 | KbdInteractiveAuthentication no 6 | RSAAuthentication no 7 | GSSAPIAuthentication no 8 | StrictHostKeyChecking yes 9 | LogLevel DEBUG 10 | 11 | # UserKnownHostsFile and ProxyCommand will be filled in dynamically. 12 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/home/testuser/.ssh/proxy-command: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # simple socket-based proxy-command wrapper for testing monkeysphere. 4 | 5 | # pass this thing the host, the port, and the socket. 6 | which monkeysphere >&2 7 | 8 | monkeysphere ssh-proxycommand --no-connect "$1" "$2" && \ 9 | exec socat STDIO UNIX:"$3" 10 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/tests/keytrans: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Tests to ensure that the monkeysphere is working 4 | 5 | # Authors: 6 | # Daniel Kahn Gillmor 7 | # Jameson Rollins 8 | # Micah Anderson 9 | # 10 | # Copyright: 2008-2009 11 | # License: GPL v3 or later 12 | 13 | # these tests should all be able to run as a non-privileged user. 14 | 15 | # all subcommands in this script should complete without failure: 16 | set -e 17 | # piped commands should return the code of the first non-zero return 18 | set -o pipefail 19 | 20 | # make sure the TESTDIR is an absolute path, not a relative one. 21 | export TESTDIR=$(cd $(dirname "$0") && pwd) 22 | 23 | source "$TESTDIR"/common 24 | 25 | perl -MCrypt::OpenSSL::RSA -e 1 2>/dev/null || { echo "You must have the perl module Crypt::OpenSSL::RSA installed to run this test. 26 | On debian-derived systems, you can set this up with: 27 | apt-get install libcrypt-openssl-rsa-perl" ; exit 1; } 28 | 29 | perl -MDigest::SHA -e 1 2>/dev/null || { echo "You must have the perl module Digest::SHA installed to run this test. 30 | On debian-derived systems, you can set this up with: 31 | apt-get install libdigest-sha1-perl" ; exit 1; } 32 | 33 | 34 | ###################################################################### 35 | ### SETUP VARIABLES 36 | 37 | ## set up some variables to ensure that we're operating strictly in 38 | ## the tests, not system-wide: 39 | 40 | mkdir -p "$TESTDIR"/tmp 41 | TEMPDIR=$(mktemp -d "${TMPDIR:-$TESTDIR/tmp}/monkeyspheretest.XXXXXXX") 42 | 43 | mkdir "$TEMPDIR"/bin 44 | ln -s "$TESTDIR"/../src/share/keytrans "$TEMPDIR"/bin/openpgp2ssh 45 | ln -s "$TESTDIR"/../src/share/keytrans "$TEMPDIR"/bin/pem2openpgp 46 | ln -s "$TESTDIR"/../src/share/keytrans "$TEMPDIR"/bin/keytrans 47 | 48 | # Use the local copy of executables first, instead of system ones. 49 | # This should help us test without installing. 50 | export PATH="$TEMPDIR"/bin:"$PATH" 51 | 52 | ## setup trap 53 | trap failed_cleanup EXIT 54 | 55 | ###################################################################### 56 | ### TEST KEYTRANS 57 | 58 | echo "##################################################" 59 | echo "### generating openpgp key..." 60 | export GNUPGHOME="$TEMPDIR" 61 | chmod 700 "$TEMPDIR" 62 | 63 | 64 | # create the key with the same preferences that monkeysphere uses. 65 | cat > "$TEMPDIR"/gpg.conf < \ 92 | "$TEMPDIR"/test.pem 93 | 94 | gpg --export-secret-key > "$TEMPDIR"/secret.key 95 | 96 | PEM2OPENPGP_USAGE_FLAGS=sign,certify \ 97 | PEM2OPENPGP_TIMESTAMP="$timestamp" pem2openpgp testtest \ 98 | < "$TEMPDIR"/test.pem > "$TEMPDIR"/converted.secret.key 99 | 100 | echo "##################################################" 101 | echo "### reconvert key, and compare to key in gpg keyring..." 102 | diff -u \ 103 | <(gpg --list-packets < "$TEMPDIR"/secret.key) \ 104 | <(gpg --list-packets < "$TEMPDIR"/converted.secret.key) 105 | 106 | diff -u \ 107 | <(hd "$TEMPDIR"/secret.key) \ 108 | <(hd "$TEMPDIR"/converted.secret.key) 109 | 110 | KEYFPR=$(gpg --fingerprint --with-colons --list-keys | grep ^fpr | cut -f10 -d:) 111 | KEYID=$(printf "%s" "$KEYFPR" | cut -b25-40) 112 | 113 | echo "conversions look good!" 114 | 115 | echo "Now working with key $KEYID at time $timestamp" 116 | 117 | gpg --check-trustdb 118 | gpg --list-keys 119 | 120 | 121 | echo "##################################################" 122 | echo "### test User ID addition..." 123 | < "$TEMPDIR"/secring.gpg \ 124 | PEM2OPENPGP_TIMESTAMP="$timestamp" \ 125 | PEM2OPENPGP_USAGE_FLAGS=sign,certify \ 126 | keytrans adduserid "$KEYID" "monkeymonkey" | gpg --import 127 | 128 | gpg --check-trustdb 129 | gpg --list-keys 130 | 131 | cat >"$TEMPDIR"/expectedout <"$TEMPDIR"/expectedout < "$TEMPDIR"/newkey.gpg 180 | 181 | NEWKEYFPR=$(< "$TEMPDIR"/newkey.gpg keytrans listfprs) 182 | NEWKEYID=$( printf "%s" "$NEWKEYFPR" | cut -b25-40) 183 | 184 | < "$TEMPDIR"/newkey.gpg gpg --import 185 | 186 | < "$TEMPDIR"/secring.gpg \ 187 | PEM2OPENPGP_TIMESTAMP="$timestamp" \ 188 | keytrans adduserid "$KEYID" "baz" | gpg --import 189 | 190 | cat >"$TEMPDIR"/expectedout <"$TEMPDIR"/expectedout < packaging/freebsd/security/monkeysphere/distinfo 10 | 11 | sed -i~ 's/^PORTVERSION=.*$/PORTVERSION= '"${VERSION}"/ packaging/freebsd/security/monkeysphere/Makefile 12 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/utils/build-macports-portfile: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | PORTFILE="packaging/macports/Portfile" 4 | 5 | VERSION=`head -n1 packaging/debian/changelog | sed 's/.*(\([^-]*\)-.*/\1/'` 6 | MD5=`md5sum monkeysphere_${VERSION}.orig.tar.gz | awk '{ print $1 }'` 7 | 8 | sed -i~ 's/^version.*$/version '"$VERSION"/ "$PORTFILE" 9 | sed -i~ 's/^checksums.*$/checksums md5 '"$MD5"/ "$PORTFILE" 10 | -------------------------------------------------------------------------------- /lib/monkeysphere-0.35/utils/preparing-release: -------------------------------------------------------------------------------- 1 | ### Notes about preparing a release for the monkeysphere ### 2 | 3 | * make sure that changelog and packaging/debian/changelog both have 4 | reasonable version numbers. 5 | 6 | * have the monkeysphere archive signing key handy! 7 | 8 | * create upstream version tag: 9 | 10 | git tag -s -m 'Tagging Monkeysphere $whatever' monkeysphere_$version master 11 | 12 | * create debian-specific version tag: 13 | 14 | git tag -s -m 'Tagging Monkeysphere $whatever-1' monkeysphere_$version-1 debian 15 | 16 | * make releasenote 17 | 18 | * upload to monkeysphere repo: 19 | 20 | (cd ../monkeysphere-docs/repo && reprepro --ignore=wrongdistribution include experimental ../../monkeysphere_$version-1_*.changes) 21 | 22 | * upload to debian: 23 | 24 | (cd .. && dupload monkeysphere_$version-1_*.changes) 25 | 26 | * git push central master debian && git push --tags central master debian 27 | 28 | * switch over to monkeysphere-docs, inspect, and then push out those changes. 29 | -------------------------------------------------------------------------------- /lib/python-gnupg-0.3.3/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2013 by Vinay Sajip. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * The name(s) of the copyright holder(s) may not be used to endorse or 13 | promote products derived from this software without specific prior 14 | written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) "AS IS" AND ANY EXPRESS OR 17 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 24 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | -------------------------------------------------------------------------------- /lib/python-gnupg-0.3.3/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: python-gnupg 3 | Version: 0.3.3 4 | Summary: A wrapper for the Gnu Privacy Guard (GPG or GnuPG) 5 | Home-page: http://packages.python.org/python-gnupg/index.html 6 | Author: Vinay Sajip 7 | Author-email: vinay_sajip@red-dove.com 8 | License: Copyright (C) 2008-2013 by Vinay Sajip. All Rights Reserved. See LICENSE for license. 9 | Download-URL: http://python-gnupg.googlecode.com/files/python-gnupg-0.3.3.tar.gz 10 | Description: This module allows easy access to GnuPG's key management, encryption and signature functionality from Python programs. It is intended for use with Python 2.4 or greater. 11 | Platform: No particular restrictions 12 | Classifier: Development Status :: 5 - Production/Stable 13 | Classifier: Intended Audience :: Developers 14 | Classifier: License :: OSI Approved :: BSD License 15 | Classifier: Programming Language :: Python 16 | Classifier: Programming Language :: Python :: 2 17 | Classifier: Programming Language :: Python :: 3 18 | Classifier: Programming Language :: Python :: 2.4 19 | Classifier: Programming Language :: Python :: 2.5 20 | Classifier: Programming Language :: Python :: 2.6 21 | Classifier: Programming Language :: Python :: 2.7 22 | Classifier: Programming Language :: Python :: 3.0 23 | Classifier: Programming Language :: Python :: 3.1 24 | Classifier: Programming Language :: Python :: 3.2 25 | Classifier: Operating System :: OS Independent 26 | Classifier: Topic :: Software Development :: Libraries :: Python Modules 27 | -------------------------------------------------------------------------------- /lib/python-gnupg-0.3.3/README: -------------------------------------------------------------------------------- 1 | To install this package from a source distribution, do the following. 2 | 3 | 1. Extract all the files in the distribution archive to some directory on your system. 4 | 2. In that directory, run "python setup.py install". 5 | 3. Optionally, run "python test_gnupg.py" to ensure that the package is working as expected. 6 | -------------------------------------------------------------------------------- /lib/python-gnupg-0.3.3/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | 3 | from gnupg import __version__ as version 4 | 5 | setup(name = "python-gnupg", 6 | description="A wrapper for the Gnu Privacy Guard (GPG or GnuPG)", 7 | long_description = "This module allows easy access to GnuPG's key \ 8 | management, encryption and signature functionality from Python programs. \ 9 | It is intended for use with Python 2.4 or greater.", 10 | license="""Copyright (C) 2008-2013 by Vinay Sajip. All Rights Reserved. See LICENSE for license.""", 11 | version=version, 12 | author="Vinay Sajip", 13 | author_email="vinay_sajip@red-dove.com", 14 | maintainer="Vinay Sajip", 15 | maintainer_email="vinay_sajip@red-dove.com", 16 | url="http://packages.python.org/python-gnupg/index.html", 17 | py_modules=["gnupg"], 18 | platforms="No particular restrictions", 19 | download_url="http://python-gnupg.googlecode.com/files/python-gnupg-%s.tar.gz" % version, 20 | classifiers=[ 21 | 'Development Status :: 5 - Production/Stable', 22 | "Intended Audience :: Developers", 23 | 'License :: OSI Approved :: BSD License', 24 | "Programming Language :: Python", 25 | "Programming Language :: Python :: 2", 26 | "Programming Language :: Python :: 3", 27 | "Programming Language :: Python :: 2.4", 28 | "Programming Language :: Python :: 2.5", 29 | "Programming Language :: Python :: 2.6", 30 | "Programming Language :: Python :: 2.7", 31 | "Programming Language :: Python :: 3.0", 32 | "Programming Language :: Python :: 3.1", 33 | "Programming Language :: Python :: 3.2", 34 | "Operating System :: OS Independent", 35 | "Topic :: Software Development :: Libraries :: Python Modules" 36 | ] 37 | ) 38 | -------------------------------------------------------------------------------- /trollwot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micahflee/trollwot/5baede1f0e6b05bf878e6be3c2803f25337b0cde/trollwot.pdf --------------------------------------------------------------------------------