Backup devices using SSH keys

Using ssh keys to open an ssh connection is possible, however not straight forward and not supported by the GUI.

Steps to get there:

Exposing the private key to be used:

1. save the key to a secure enough directory, <private-key-dir>

2. map that directory into the agent’s file system by adding a new volume:

volumes:
- <private-key-dir>:/private-keys

3. add a new vault via UI: e.i. “by-keys”

4. modify the vault via cli:

vault="by-keys"
vault_file="$(docker volume inspect netpicker_secret --format '{{ .Mountpoint }}')/vaults.json"
cat "${vault_file}" | jq ".\"${vault}\".ssh.use_keys=true | .\"${vault}\".ssh.key_file=\"/private-keys/id_rsa\"" >"${vault_file}"

to verify:

cat "${vault_file}" | jq ".\"${vault}\".ssh"
{
"username": ...,
"use_keys": true,
"key_file": "private-keys/id_rsa"
}

After this, the device is accessible via the key.

If you ever edit the vault via the GUI, the steps need to be repeated.