Created
December 30, 2015 20:50
-
-
Save spangey/24140e8885673fbc82c1 to your computer and use it in GitHub Desktop.
encryptPlainTxtAuthFilles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A very convenient feature of Curl is that if invoked with curl -n, it will try to read credentials | |
of a target service from a local .netrc file, and if found, use them for authentication. The trouble | |
is that these credentials default to being stored in plain text, which is something that we’d like to avoid by using GPG. | |
The first step here is to encrypt your .netrc: | |
$ gpg -r <your email> -e ~/.netrc | |
$ ls ~/.netrc.gpg | |
$ rm ~/.netrc | |
Now we can can pipe the decrypted output of our .netrc file from gpg, and have Curl read it in (this should go in your appropriate *rc file): | |
$ alias curl="gpg --batch -q -d ~/.netrc.gpg | curl --netrc-file /dev/stdin" | |
Because we’ve folded this into an alias, curl can be invoked normally: | |
$ curl -n https://api.heroku.com/apps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment