Hack-R Hack-R - 4 months ago 22
R Question

How to correctly setup keys with Hadley's secure package

I would like to use Hadley Wickam's

package from GitHub.

The example usage isn't explicit about how to create keys and where to store them and I'm messing something up (possibly more than one thing).

I installed the package

# install.packages("devtools")
devtools::install_github("s-u/PKI") # needed for bug fixes not currently on CRAN

set up a


Then the next step is to add a user / key:

secure::add_user("hackr", local_key())

and of course if I literally run that last line as-is it says

Error: No key matches id_rsa

Because I don't have a key. So, I used PuttyGen to create a public/private RSA key pair.

I saved them to my desktop and tried putting the full path in the command above:

secure::add_user("hackr", local_key("C:/Users/hackr/Desktop/r_public_key"))

But that didn't work:

Error: No key matches

Then I tried saving the public key in the vault and doing:

secure::add_user("hackr", local_key("r_public_key"))

but I got the same error. Next I tried putting the public key in the working directory (one directory higher than the vault) but got the same error.

Finally, I tried copying the keys to
but that also led to the same error.

I suspect I need to save the key somewhere special (in Windows I'm not sure where that would be?) and/or I am using the wrong type of key since PuttyGen is for SSH (?).


It looks like local_key is assuming your key is stored in ~/.ssh (which is a reasonable assumption). By default it assumes that the file is named id_rsa.pub so if you've renamed it then you'll need to pass the name into local_key.

I haven't used this package but always remember those wise words "Hack-R view the source"