195

I have a new mac pro (OS X 10.9.5) that I get to set up from scratch. I want to install RVM and the first thing it says to do is:

Install mpapis public key (might need gpg2 and or sudo)

gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

When I tried I got:

gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
zsh: command not found: gpg

I've tried to find a good guide on how to overcome this that also looks trustworthy but I've had no luck.

Can someone explain what gpg is, why I dont already have it, and how do I get it the right way.

biniam
  • 8,099
  • 9
  • 49
  • 58
JDillon522
  • 19,046
  • 15
  • 47
  • 81
  • 1
    did you try "gpg" in Google? It's public key encryption, and you need to install the appropriate tool either by hand or from Brew or Macports. Also not exactly a StackOverflow question. – ofrommel Nov 20 '14 at 14:25
  • 1
    Hi guys, if you are trying to set up RVM in 2021 or later and found this issue, after you installed by brew and run the command on RVM again, you will see "gpg: keyserver receive failed: No name" error, that's because the SKS Keyserver Network is being deprecated. You need to change the keyserver to another one, like run "gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB". From . – Harry Yu Aug 20 '21 at 23:42

9 Answers9

343

GnuPG (with binary name gpg) is an application used for public key encryption using the OpenPGP protocol, but also verification of signatures (cryptographic signatures, that also can validate the publisher if used correctly). To some extend, you could say it's for OpenPGP what OpenSSL is for X.509 and TLS.

Unlike most Linux distributions (which make heavy use of GnuPG for ensuring untampered software within their package repositories), Mac OS X does not bring GnuPG with the operating system, so you have to install it on your own.

Possible sources are:

  • Package manager Homebrew: brew install gnupg gnupg2
  • Package manager MacPorts: sudo port install gnupg gnupg2
  • Install from GPGTools, which also brings GUI applications and integration in Apple Mail
Jens Erat
  • 37,523
  • 16
  • 80
  • 96
  • I had the exact same issue as the original question asked by JDillon522. To install RVM I only installed `gpg2`. This answer helped me to additionally install `gpg`. – Brian Zelip Jul 21 '15 at 00:19
  • brew install gnupg gnupg2 -> Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink share/man/man8/addgnupghome.8 /usr/local/share/man/man8 is not writable. – ProGirlXOXO Dec 19 '15 at 00:45
  • This sounds like some other package/package manager changed permissions for that folder. `brew doctor` might indicate the problem and suggest solutions, but generally I'd rather ask for help at Ask Different, using a package manager is rather off topic on Stack Overflow. – Jens Erat Dec 19 '15 at 07:47
  • 8
    Installing via homebrew didn't seem to work for me. Despite the process completing without a problem the gpg command was still unavailable. I ended up using gpg tools which made the command available. – foamcow Feb 23 '17 at 17:42
  • I guess that something wrent wrong setting up your `$PATH` variable. – Jens Erat Feb 23 '17 at 18:05
  • how to install gnupg gnupg2 on **windows** as brew installer is for mac only? – taranjeetsapra Apr 12 '17 at 07:44
  • You're probably best off with the [GPG4Win distribution](https://www.gpg4win.org/) of GnuPG, which also includes an installer. If you still have issues with `gpg` not being found, make sure your `%PATH%` variable is set up properly. – Jens Erat Apr 12 '17 at 19:21
  • brew doctor worked to help me get it working after I was getting the gpg command not found. – Brian Ball Oct 30 '19 at 05:03
34

As the instruction said "might need gpg2"

In mac, you can try install it with homebrew

$ brew install gpg2 
rderoldan1
  • 3,517
  • 26
  • 33
  • 2
    If you don't have homebrew, you can install it on Mac OS X with the command: `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` See (http://coolestguidesontheplanet.com/installing-homebrew-os-x-yosemite-10-10-package-manager-unix-apps/) for more information. – dwsolberg Feb 15 '15 at 17:34
  • 2
    A user will also need to install `gpg` in addition to `gpg2`, see the answer by Jens Erat. – Brian Zelip Jul 21 '15 at 00:20
26

On Mac OSX 10.15, Even after installing gpg, i was getting gpg2 command not found

$ brew install gnupg gnupg2
Warning: gnupg 2.2.23 is already installed and up-to-date
To reinstall 2.2.23, run `brew reinstall gnupg`

$ gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
-bash: gpg2: command not found

Instead, this worked for me

$ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Ashish Pani
  • 933
  • 1
  • 12
  • 19
  • Seconding that running with `keyserver` flag worked! – C13L0 Nov 13 '20 at 16:35
  • Got 'gpg: keyserver receive failed: No name' with command as given. Tried a different keyserver and worked. – joedragons Nov 11 '21 at 23:23
  • 2
    Yep, first 2 key servers from sks-keyservers.net don't work for me now. 3rd one from https://rvm.io/rvm/security worked: `gpg --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB` – Denis V Jan 10 '22 at 17:55
  • 1
    Had the same problem and the gpg one worked! – Frank Guo Mar 02 '22 at 13:39
11

Here are the steps to install RVM.

Step 1: Install gpg or gpg2 (both work)

brew install gpg

Step 2: Install GPG keys used to verify installation package:

gpg --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

If you encounter problem with the key server above, try a different one.

  • hkp://ipv4.pool.sks-keyservers.net
  • hkp://pgp.mit.edu
  • hkp://keyserver.pgp.com

Step 3: Install RVM

\curl -sSL https://get.rvm.io | bash -s stable

Check out the Security page if you still run into problems.

software_writer
  • 3,941
  • 9
  • 38
  • 64
7

This worked for me

$brew install gnupg
Sevle
  • 3,109
  • 2
  • 19
  • 31
valmsmith39a
  • 71
  • 1
  • 3
2

After installing gpg using:

brew install gnupg2

This solution helped me get the keys to install rvm:

curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
A. KUMAR
  • 330
  • 1
  • 9
1

On my clean macOS 10.15.7, I needed to brew link gnupg && brew unlink gnupg first and then used Ashish's answer to use gpg instead of gpg2. I also had to chown a few directories. before the un/link.

Jeff
  • 13,943
  • 11
  • 55
  • 103
1

I was facing the same issue when I was trying to install RVM on a UNIX Apple M1.

I can solved my issue with this command:

gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Instead of use gpg2:

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

After run the command I had this output:

gpg: key 195BD3E759199BDB: 1 duplicate signature removed
gpg: /Users/User/.gnupg/trustdb.gpg: trustdb created
gpg: key 105BD0E739499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: key 3804BB82D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: Total number processed: 2
gpg:               imported: 2

Note: Don't forget to restart your command console.

-11

You can also use:

$ sudo gem install rvm

It should give you the following output:

Fetching: rvm-1.11.3.9.gem (100%)
Successfully installed rvm-1.11.3.9
Parsing documentation for rvm-1.11.3.9
Installing ri documentation for rvm-1.11.3.9
1 gem installed
Reza Malik
  • 39
  • 1