From 3c1adc852576ee384605644566305d6f57bed8ea Mon Sep 17 00:00:00 2001 From: Grégoire Duchêne Date: Sat, 8 Jul 2023 12:30:29 +0100 Subject: zsh: Remove op-ssh-add See https://developer.1password.com/docs/ssh/agent for a better replacement. --- zsh/functions/op-ssh-add | 58 ------------------------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 zsh/functions/op-ssh-add (limited to 'zsh/functions/op-ssh-add') diff --git a/zsh/functions/op-ssh-add b/zsh/functions/op-ssh-add deleted file mode 100644 index 6bbdd13..0000000 --- a/zsh/functions/op-ssh-add +++ /dev/null @@ -1,58 +0,0 @@ -# -*- mode: sh -*- - -# op-ssh-add will add SSH keys to the agent, but will fetch the -# passphrase in 1Password rather than prompt you for it. -# -# To be found, keys must have the following three things: -# -# 1. Have the password field set to the passphrase of the key, -# 2. Have an ‘SSH’ tag set, and -# 3. Have a ‘fingerprint’ field set to the fingerprint of the key. -# -# You must also have the 1Password CLI 2 installed. - -if [[ ${@[1]} =~ '-[DdKLlTXx]' ]]; then - command ssh-add $@ - return $? -fi - -local args=$@ fp prv pub -for prv (${@[-1]} ~/.ssh/id_{ecdsa,ed25519}{_sk,}); do - if [[ -f ${prv}.pub ]]; then - pub=${prv}.pub - fp=$(cut -d' ' -f2 <<< $(ssh-keygen -f ${pub} -l)) - if [[ ${prv} != ${@[-1]} ]]; then - args+=(${prv}) - fi - break - fi -done - -if [[ -z ${pub} ]]; then - command ssh-add $@ - return $? -fi - -local session=$(op signin --raw) -if [[ -z ${session} ]]; then - return 1 -fi - -zmodload zsh/zpty -zpty ssh command ssh-add ${args} - -_cleanup() { - zpty -d ssh - op signout --session $1 - trap - - unfunction _cleanup -} -trap "_cleanup ${session}" EXIT HUP INT TERM - -zpty -w ssh $(trap - - op item list --format json --session ${session} --tags SSH \ - | op item get \ - --fields fingerprint,password \ - --session ${session} - \ - | grep ${fp} | cut -d, -f2) -zpty -r ssh -- cgit v1.2.3-70-g09d2