Skip to content

Instantly share code, notes, and snippets.

@brianddk
Last active September 1, 2015 03:40
Show Gist options
  • Select an option

  • Save brianddk/4c2f250f3c6f277a9e87 to your computer and use it in GitHub Desktop.

Select an option

Save brianddk/4c2f250f3c6f277a9e87 to your computer and use it in GitHub Desktop.
Gnu Privacy Guard on OS X without Administrator

Install GnuPG on OS X without Admin privilege

The current GnuPG installer requires Admin privilege to gain access to various system level directories. The goal of the HowTo is walk through the steps to get GnuPG into user space.

Steps from OS X terminal

  1. Move to home directory
  2. cd ~
  3. Download GnuPG
  4. curl -LO http://downloads.sourceforge.net/project/gpgosx/GnuPG-2.1.7.dmg
  5. curl -LO http://downloads.sourceforge.net/project/gpgosx/GnuPG-2.1.7.dmg.sig
  6. Make Directorys for the files
  7. mkdir GnuPG
  8. mkdir GnuPG/tmp
  9. Extract the dmg
  10. cd ~/GnuPG/tmp
  11. 7z x ../../GnuPG-2.1.7.dmg
  12. 7z x 4.hfs
  13. tar -xf Install.pkg
  14. cd ..
  15. cat tmp/GnuPG.pkg/Payload | gunzip -dc |cpio -i
### No shebang since I want to set the environment
### for the current shell
if [ -z "$GNUPGHOME" ]; then
# begin if; not indented b/c of heredocs
## Create GnuPG directory with a dmg and tmp subdir
2>/dev/null mkdir ~/GnuPG
2>/dev/null mkdir ~/GnuPG/tmp
2>/dev/null mkdir ~/GnuPG/dmg
## Download dmg, sig, and signing keys to dmg subdir
cd ~/GnuPG/dmg
gpgosx=http://downloads.sourceforge.net/project/gpgosx
enigmail=https://www.enigmail.net/documentation
# Download dmg
curl -LO ${gpgosx}/GnuPG-2.1.7.dmg
# Download sig
curl -LO ${gpgosx}/GnuPG-2.1.7.dmg.sig
# Download signing keys
curl -LO ${enigmail}/pgp-key.php
## Extract temp files to tmp directory
cd ~/GnuPG/tmp
# Mount DMG while saving off the device allocated
dmgdev=$(hdiutil attach ../dmg/GnuPG-2.1.7.dmg \
| grep /dev/disk | head -n 1 | awk '{print $1}')
# Extract the pkg file contents
tar -xf /Volumes/GnuPG\ 2.1/Install.pkg
# Unmount the dmg file
hdiutil detach $dmgdev
# Extract the directory stucture to GnuPG directory
cd ~/GnuPG
cat ./tmp/GnuPG.pkg/Payload | gunzip -dc |cpio -i
## Set up profile and config files
# Set up GnuPG environment
touch ~/.profile ./setGnuPGenv.sh
> ./setGnuPGenv.sh cat << EOL
if [ -z "\$GNUPGHOME" ]; then
export PATH=\${PATH}:${PWD}/bin
export DYLD_FALLBACK_LIBRARY_PATH=${PWD}/lib
export GNUPGHOME=\${HOME}/.gnupg
fi
EOL
>> ~/.profile cat << 'EOL'
if [ -z "$GNUPGHOME" ]; then
source ~/GnuPG/setGnuPGenv.sh
fi
EOL
source ~/GnuPG/setGnuPGenv.sh
# Set up GnuPG config files
> ${GNUPGHOME}/gpg.conf echo "agent-program" \
"${PWD}/bin/gpg-agent"
> ${GNUPGHOME}/gpg-agent.conf echo "pinentry-program" \
"${PWD}/bin/pinentry-mac.app/Contents/MacOS/pinentry-mac"
## Verify the dmg we downloaded
cd ~/GnuPG/dmg
gpg2 --import pgp-key.php
gpg2 --verify GnuPG-2.1.7.dmg.sig GnuPG-2.1.7.dmg
if [ $? -eq 0 ]; then
# Verify worked, files are good.
rm -r -f ~/GnuPG/tmp
else
# Verify failed, files are corrupt
echo "ERROR: SIGNATURE CHECK FAILED!"
export GNUPGHOME=""
fi
# end if; not indented b/c of heredocs
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment