The long and short is: it depends!
A long, strong, random passphrase encrypted properly with lots of iterations is very safe
- unless there's a flaw in gpg somewhere (which is possible, of course), very safe.
A weak passphrase is always unsafe.
A small number of iterations on encryption makes the area of "weak passphrase" bigger, and the area of "strong passphrase" smaller.
Let's experiment, so you can see for yourself!
We'll more or less start with the Ubuntuvibes article Recover your gpg passphrase using John the Ripper.
Create a GPG key, nice and default, with a weak passphrase to validate the technique:
gpg --gen-key
Follow the defaults FOR THIS DEMONSTRATION, but name it "CrackingTestDefault"
To change the passphrase, you can simply use the following and then re-export to try again!
gpg --edit-key <keyid>
passwd
Now, export the test secret key
gpg -a -o ctd.asc --export-secret-key CrackingTestDefault
Download and compile John the Ripper 1.8.0-jumbo-1 or the latest when you read this - configure and compile. Or just use Kali linux.
Now extract the important bits into John's format using a John the Ripper helper app that came with the Jumbo version
run/gpg2john ctd.asc >ctd.john
Now let's just try the default mode and see what happens
IF your weak password was TestTest, like mine, then you found it nearly instantly! Let's show the password
run/john --show ctd.john
See our password of TestTest?
Reset John's list of cracked passwords, the "pot", and do something different just to show what people are talking about when they say a password will take days (on an 8 core CPU)
mv run/john.pot run/john.pot.found1
Now let's try incremental mode, lower case only, and see what happens
run/john --format=gpg --mask=?u?l?l?l?u?l?l?l ctd.john
Let it settle out for a few seconds, then check your CPU use and hit a key. If you compiled John correctly, it's maxed out all your CPU cores, and it's still going to take a few weeks, because it is - STUPIDLY - trying every single combination.
Note the speed - on my 8 core box, it's getting right around 50,000 guesses per second. That's 129.6 BILLION guesses every 30 days, and a targeted attack against a GPG passphrase is likely to be worth quite a lot more than most password cracking exercises, so expect more than a single CPU running for more than a single month!
Let's try a real rule
Press Ctrl-C and stop it. Mask attacks are fine for very small keyspaces, or very fast hashes.
Try a real attack - a rules-based wordlist attack!
run/john --format=gpg --wordlist=run/password.lst --rules:Jumbo ctd.john
It shouldn't take long to find TestTest, or Test7, or quite a few other word based passwords. Play with it!
Rule #1 - Use a long, strong, random GPG passphrase.
If your passphrase is weak by the definition of cracking attacks
Let's try something else! Let's try changing how GPG protects the key!
We're going to encrypt the key with AES256, use a SHA-512 digest, and drastically increase our iteration count.
Change the password to Chameleon98 now:
gpg --s2k-mode 3 --s2k-digest-algo SHA512 --s2k-cipher-algo AES256 --s2k-count 70000000 --edit-key CrackingTestDefault
passwd
enter your old password, then Chameleon98, the new password, twice
save
Now, use the previous instructions to extract it to ctdcham.asc, create ctdcham.john, and attack it.
If your system is like mine, the cracking speed is now about 32 guesses per second, instead of 50,000 guesses per second; more than three orders of magnitude slower.
Now, unless you want to wait for the hours or days your machine will take to go through the entire John wordlist with that ruleset, you can create a file called cham.lst, with a single line that has the word
chameleon
in it, and use THAT as your wordlist with the Jumbo rules based attack above just to see if Chameleon98 is vulnerable to the Jumbo ruleset. You will, in fact, see that John the Ripper will use the base word, and it will finally get to a rule that capitalizes the first letter and adds 98 to the end, cracking it - but now it takes quite a lot longer.
WARNING: the Jumbo ruleset is not the be-all or end-all. See some of the rulesets that come with Hashcat which are much, much longer, and Hashcat has rules John doesn't, too, though as of Jan 2016 I don't think Hashcat has a mode for GPG in specific.
WARNING: Whenever the gpg attack is ported to GPU, the attack may get a MASSIVE speedup.
Try decrypting a file, too - note there's a second or two's pause (more on a slower CPU) after entering your passphrase. Cracking takes 1500 times longer; well, normally use of the passphrase ALSO takes 1500 times longer. However, unless you're decrypting lots and lots of files, you can probably afford to take a couple seconds after entering your passphrase, in exchange for making attackers spend more resources and/or test a smaller keyspace.
Rule #2: Use the --s2k* options when generating keys, AND when changing passphrases!!!
Feel free to use Luis Rocha's JtR cheat sheet to play around further.