User commands
Usage
data_request_access(path_data = NULL, path_user = NULL, quiet = FALSE)
data_key(
path_data = NULL,
path_user = NULL,
test = TRUE,
quiet = FALSE,
cache = TRUE
)
Arguments
- path_data
Path to the data. If not given, then we look recursively down below the working directory for a ".cyphr" directory, and use that as the data directory.
- path_user
Path to the directory with your user key. Usually this can be omitted. This argument is passed in as both
pub
andkey
tokeypair_openssl()
. Briefly, if this argument is not given we look at the environment variablesUSER_PUBKEY
andUSER_KEY
- if set then these must refer to path of your public and private keys. If these environment variables are not set then we fall back on~/.ssh/id_rsa.pub
and~/.ssh/id_rsa
, which should work in most environments. Alternatively, provide a path to a directory where the fileid_rsa.pub
andid_rsa
can be found.- quiet
Suppress printing of informative messages.
- test
Test that the encryption is working? (Recommended)
- cache
Cache the key within the session. This will be useful if you are using ssh keys that have passwords, as if the key is found within the cache, then you will not have to re-enter your password. Using
cache = FALSE
neither looks for the key in the cache, nor saves it.
Examples
# The workflow here does not really lend itself to an example,
# please see the vignette.
# Suppose that Alice has created a data directory:
path_alice <- tempfile()
cyphr::ssh_keygen(path_alice, password = FALSE)
path_data <- tempfile()
dir.create(path_data, FALSE, TRUE)
cyphr::data_admin_init(path_data, path_user = path_alice)
#> Generating data key
#> Authorising ourselves
#> Adding key 02:86:09:5c:d8:bc:e4:f8:5f:d2:ca:62:81:b6:33:29:81:db:5e:45:c9:b2:d9:af:e4:ff:c2:87:e0:b3:9f:29
#> user: root
#> host: 709e98efa5ba
#> date: 2024-10-28 06:06:20.516372
#> Verifying
# If Bob can also write to the data directory (e.g., it is a
# shared git repo, on a shared drive, etc), then he can request
# access
path_bob <- tempfile()
cyphr::ssh_keygen(path_bob, password = FALSE)
hash <- cyphr::data_request_access(path_data, path_user = path_bob)
#> A request has been added
#> Email someone with access to add you
#>
#> hash: f4:a2:47:22:16:05:0a:78:a4:e6:5b:c2:8b:10:f9:56:15:cd:63:ab:b6:36:aa:8f:7c:40:c6:63:57:0d:44:4c
#>
#> If you are using git, you will need to commit and push first:
#>
#> git add .cyphr
#> git commit -m "Please add me to the dataset"
#> git push
# Alice can authorise Bob
cyphr::data_admin_authorise(path_data, path_user = path_alice, yes = TRUE)
#> There is 1 request for access
#> Adding key f4:a2:47:22:16:05:0a:78:a4:e6:5b:c2:8b:10:f9:56:15:cd:63:ab:b6:36:aa:8f:7c:40:c6:63:57:0d:44:4c
#> user: root
#> host: 709e98efa5ba
#> date: 2024-10-28 06:06:20.729685
#> Added 1 key
#> If you are using git, you will need to commit and push:
#>
#> git add .cyphr
#> git commit -m "Authorised root"
#> git push
# After which Bob can get the data key
cyphr::data_key(path_data, path_user = path_bob)
#> <cyphr_key: sodium>
# See the vignette for more details. This is not the best medium
# to explore this.
# Cleanup
unlink(path_alice, recursive = TRUE)
unlink(path_bob, recursive = TRUE)
unlink(path_data, recursive = TRUE)