Skip to content

Commit

Permalink
Add some key directory customization variables
Browse files Browse the repository at this point in the history
  • Loading branch information
eritbh committed Jan 11, 2022
1 parent dc45217 commit 9e828e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Utilities for storing and loading SSH keys with 1password

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.

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.

### Create a new SSH item in the vault

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

# Todos

- Find a better place to store keys locally (is /dev/shm appropriate?) + allow user to customize that location
- 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?)
- Better vault item searching/handling, customization of the item template
- Guidance for adding items to 1Password manually so that this tool can pick them up
13 changes: 9 additions & 4 deletions common.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# If the user doesn't specify anything, use /dev/shm if
# available, otherwise use /tmp and hopefully it's tmpfs.
if [ -d /dev/shm ]; then
default_tmpdir="/dev/shm"
else
default_tmpdir="/tmp"
fi
export default_temp_storage_root="${OP_KEY_STORAGE_LOCATION:-${TMPDIR:-$default_tmpdir}/op-ssh-utils}"

# Signs into `op` or exits the script
function op_signin {
echo "Signing into 1Password..."
eval "$(op signin $@ || echo 'echo "Sign-in failed." >&2; exit 1')"
}

# Ideally something that won't ever actually be written to disk, but we'll worry
# about that later
export default_temp_storage_root="/tmp/op-ssh-utils"

# Writes the public/private key pair for a given vault item to the temporary
# storage directory, and adds a rule to the temporary ssh config for the host
# and user.
Expand Down

0 comments on commit 9e828e9

Please sign in to comment.