Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit 9e828e9

Browse files
committed
Add some key directory customization variables
1 parent dc45217 commit 9e828e9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Utilities for storing and loading SSH keys with 1password
66

77
Note that interactive execution is not supported for any of these scripts, since `op signin` is required for all scripts and itself requires interactive password input.
88

9+
By default, the key storage location is `$TMPDIR/op-ssh-utils`, where `TMPDIR` defaults to `/dev/shm` or `/tmp`, whichever is available. The key storage location can be overridden for all commands with the `OP_KEY_STORAGE_LOCATION` environment variable.
10+
911
### Create a new SSH item in the vault
1012

1113
$ ./op-create-identity -H <hostname>
@@ -27,7 +29,6 @@ Search for SSH key items in your vault and read them all into temporary storage.
2729

2830
# Todos
2931

30-
- Find a better place to store keys locally (is /dev/shm appropriate?) + allow user to customize that location
3132
- Use a different temporary location to allow multiple users on the same system to use the tool (random folder names in the folder symlinked to `~/.local` or something? maybe just make it a bashrc script that automates adding the `Include` rule to the user's SSH config without requiring a persistent directory name across logins?)
3233
- Better vault item searching/handling, customization of the item template
3334
- Guidance for adding items to 1Password manually so that this tool can pick them up

Diff for: common.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
# If the user doesn't specify anything, use /dev/shm if
2+
# available, otherwise use /tmp and hopefully it's tmpfs.
3+
if [ -d /dev/shm ]; then
4+
default_tmpdir="/dev/shm"
5+
else
6+
default_tmpdir="/tmp"
7+
fi
8+
export default_temp_storage_root="${OP_KEY_STORAGE_LOCATION:-${TMPDIR:-$default_tmpdir}/op-ssh-utils}"
9+
110
# Signs into `op` or exits the script
211
function op_signin {
312
echo "Signing into 1Password..."
413
eval "$(op signin $@ || echo 'echo "Sign-in failed." >&2; exit 1')"
514
}
615

7-
# Ideally something that won't ever actually be written to disk, but we'll worry
8-
# about that later
9-
export default_temp_storage_root="/tmp/op-ssh-utils"
10-
1116
# Writes the public/private key pair for a given vault item to the temporary
1217
# storage directory, and adds a rule to the temporary ssh config for the host
1318
# and user.

0 commit comments

Comments
 (0)