Create openssl key pairs in the manner of ssh-keygen(1). In general this should not be used (generate keys yourself with ssh-keygen at the command line. However this is useful for testing and demonstration so I have included it to make that easier. Once a keypair has been generated it can be used with keypair_openssl().

ssh_keygen(path = tempfile(), password = TRUE, use_shell = FALSE)



A directory in which to create a keypair. If the path does not exist it will be created.


The password for the key. The default will prompt interactively (but without echoing the password). Other valid options are FALSE (no password) or a string.


Try to use ssh-keygen (the shell utility) rather than functions in the openssl package. This will be necessary on at least very old versions of OS/X (Yosemite and older at least) where the keys generated by the openssl package cannot be read by the system ssh commands (e.g., ssh-add).


The path, invisibly. This is useful in the case where path is tempfile().


# Generate a new key in a temporary directory: path <- cyphr::ssh_keygen(password = FALSE) dir(path) # will contain id_rsa and
#> [1] "id_rsa" ""
# This key can now be used via keypair_openssl: key <- cyphr::keypair_openssl(path, path) secret <- cyphr::encrypt_string("hello", key) cyphr::decrypt_string(secret, key)
#> [1] "hello"
# Cleanup unlink(path, recursive = TRUE)