ssh_keygen: Create ssh keypairs

View source: R/openssl_keygen.R

ssh_keygenR Documentation

Create ssh keypairs

Description

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().

Usage

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

Arguments

path

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

password

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.

use_shell

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).

Value

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

Examples

# Generate a new key in a temporary directory:
path <- cyphr::ssh_keygen(password = FALSE)
dir(path) # will contain id_rsa and id_rsa.pub

# 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)

# Cleanup
unlink(path, recursive = TRUE)

dide-tools/encryptr documentation built on Aug. 29, 2023, 11:55 p.m.