From 5a9d9553cd6861d80cc958132ab5af40fe661ac4 Mon Sep 17 00:00:00 2001 From: Simone Gaiarin Date: Thu, 26 Aug 2021 11:42:17 +0200 Subject: feat(ssh-agent): allow using external helper to ask for passwords (#7631) --- plugins/ssh-agent/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins/ssh-agent/README.md') diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index 8765a9c7e..f46e8bf6a 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -55,6 +55,15 @@ ssh-add -K -c -a /run/user/1000/ssh-auth For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`. +---- + +To set an **external helper** to ask for the passwords and possibly store +them in the system keychain use the `helper` style. For example: + +```zsh +zstyle :omz:plugins:ssh-agent helper ksshaskpass +``` + ## Credits Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html -- cgit v1.2.3-70-g09d2 From 4a69ee575c9a8ec96fb6378fecae7777c7afba84 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 26 Aug 2021 15:52:09 +0200 Subject: feat(ssh-agent): allow specifying absolute path to `identities` Fixes #9650 --- plugins/ssh-agent/README.md | 9 +++++++++ plugins/ssh-agent/ssh-agent.plugin.zsh | 12 +++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'plugins/ssh-agent/README.md') diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index f46e8bf6a..d1a504b1e 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -27,6 +27,15 @@ To **load multiple identities** use the `identities` style, For example: zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github ``` +**NOTE:** the identities may be an absolute path if they are somewhere other than +`~/.ssh`. For example: + +```zsh +zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_rsa2 ~/.config/ssh/id_github +# which can be simplified to +zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github} +``` + ---- To **set the maximum lifetime of the identities**, use the `lifetime` style. diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 2049145fd..c2b9546a2 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -23,12 +23,12 @@ function _start_agent() { } function _add_identities() { - local id line sig lines + local id file line sig lines local -a identities loaded_sigs loaded_ids not_loaded zstyle -a :omz:plugins:ssh-agent identities identities # check for .ssh folder presence - if [[ ! -d $HOME/.ssh ]]; then + if [[ ! -d "$HOME/.ssh" ]]; then return fi @@ -52,10 +52,12 @@ function _add_identities() { # add identities if not already loaded for id in $identities; do + # if id is an absolute path, make file equal to id + [[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id" # check for filename match, otherwise try for signature match - if [[ ${loaded_ids[(I)$HOME/.ssh/$id]} -le 0 ]]; then - sig="$(ssh-keygen -lf "$HOME/.ssh/$id" | awk '{print $2}')" - [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$HOME/.ssh/$id") + if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then + sig="$(ssh-keygen -lf "$file" | awk '{print $2}')" + [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file") fi done -- cgit v1.2.3-70-g09d2