Key import and export
Import a key
To import a key from a file into the keystore:
$ sq key import $KEYFILE
$KEYFILE
can contain more than one key, and sq key import
will import all the keys it finds, skipping any certificates also in this file.
Export a key
To export a key from the keystore into a file to, for instance, create a backup or import it into other software like Thunderbird, redirect it into file:
$ sq key export --cert $FINGERPRINT > $KEYFILE
or use the --output
option:
$ sq key export --cert $FINGERPRINT --output $KEYFILE
You can also export a subkey instead of the complete key material:
$ sq key subkey export --cert $SUBKEY_FINGERPRINT > $KEYFILE
Please note: If exporting an unprotected key (one without a passphrase), the exported key will also be unprotected.
sq key export
will export the key as-is. To set a password for the exported key, use:
$ sq key export ... | sq key password --cert-file - --output $EXPORTED_KEY_FILE