From 3e05befaeee60a0f8522f470292c75046b05ceb9 Mon Sep 17 00:00:00 2001 From: Alexander Schlüter Date: Mon, 25 Mar 2024 12:27:21 +0100 Subject: fix(ssh-agent): don't start new agent if screen/tmux symlink exists (#12297) --- plugins/ssh-agent/ssh-agent.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugins/ssh-agent/ssh-agent.plugin.zsh') diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 49ad95a11..77c422ce1 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -98,8 +98,10 @@ function _add_identities() { # Add a nifty symlink for screen/tmux if agent forwarding is enabled if zstyle -t :omz:plugins:ssh-agent agent-forwarding \ - && [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then - ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen + && [[ -n "$SSH_AUTH_SOCK" ]]; then + if [[ ! -L "$SSH_AUTH_SOCK" ]]; then + ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen + fi else _start_agent fi -- cgit v1.2.3-70-g09d2 From 67581c53c6458566e174620361e84b364b9034d2 Mon Sep 17 00:00:00 2001 From: Zikoeng Xi Date: Tue, 23 Apr 2024 03:37:17 +0800 Subject: fix(ssh-agent): add identity only if identity exists (#12371) --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/ssh-agent/ssh-agent.plugin.zsh') diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 77c422ce1..1da54d4dd 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -62,7 +62,7 @@ function _add_identities() { # 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)$file]} -le 0 ]]; then + if [[ -f $file && ${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 -- cgit v1.2.3-70-g09d2 From 2abecedf67f47f0b39ee31b38705630eaa8dc21f Mon Sep 17 00:00:00 2001 From: Mattias Eriksson <6420639+snaggen@users.noreply.github.com> Date: Tue, 10 Sep 2024 11:32:18 +0200 Subject: feat(ssh-agent): support `id_ed25519_sk` (#12663) --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/ssh-agent/ssh-agent.plugin.zsh') diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 1da54d4dd..35d06384d 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -43,7 +43,7 @@ function _add_identities() { # this is to mimic the call to ssh-add with no identities if [[ ${#identities} -eq 0 ]]; then # key list found on `ssh-add` man page's DESCRIPTION section - for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do + for id in id_rsa id_dsa id_ecdsa id_ed25519 id_ed25519_sk identity; do # check if file exists [[ -f "$HOME/.ssh/$id" ]] && identities+=($id) done -- cgit v1.2.3-70-g09d2 From 2a2f8ecb67674538b4b267f0796673f779f0ae5d Mon Sep 17 00:00:00 2001 From: flyingpeakock Date: Fri, 27 Sep 2024 09:40:15 +0000 Subject: fix(ssh-agent): use termux prefix for tmp (#12695) --- plugins/ssh-agent/ssh-agent.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins/ssh-agent/ssh-agent.plugin.zsh') diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 35d06384d..83548648b 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -100,7 +100,11 @@ function _add_identities() { if zstyle -t :omz:plugins:ssh-agent agent-forwarding \ && [[ -n "$SSH_AUTH_SOCK" ]]; then if [[ ! -L "$SSH_AUTH_SOCK" ]]; then - ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen + if [[ -n "$TERMUX_VERSION" ]]; then + ln -sf "$SSH_AUTH_SOCK" "$PREFIX"/tmp/ssh-agent-$USERNAME-screen + else + ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen + fi fi else _start_agent -- cgit v1.2.3-70-g09d2 From d2d5155d41cbe183ef172fef1e83a29d116a5af6 Mon Sep 17 00:00:00 2001 From: Щанников Михаил <79425045+mikhailde@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:39:07 +0300 Subject: feat(ssh-agent): add keys regardless of filename (#12741) Co-authored-by: Carlo Sala --- plugins/ssh-agent/ssh-agent.plugin.zsh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'plugins/ssh-agent/ssh-agent.plugin.zsh') diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 83548648b..becd5ea17 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -39,13 +39,16 @@ function _add_identities() { return fi - # add default keys if no identities were set up via zstyle - # this is to mimic the call to ssh-add with no identities - if [[ ${#identities} -eq 0 ]]; then - # key list found on `ssh-add` man page's DESCRIPTION section - for id in id_rsa id_dsa id_ecdsa id_ed25519 id_ed25519_sk identity; do - # check if file exists - [[ -f "$HOME/.ssh/$id" ]] && identities+=($id) + # If no keys specified in zstyle, add default keys. + # Mimics calling ssh-add with no arguments. + if [[ ${#identities[@]} -eq 0 ]]; then + # Iterate over files in .ssh folder. + for file in "$HOME/.ssh"/*; do + # Check if file is a regular file and starts with "-----BEGIN OPENSSH PRIVATE KEY-----". + if [[ -f "$file" && $(command head -n 1 "$file") =~ ^-----BEGIN\ OPENSSH\ PRIVATE\ KEY----- ]]; then + # Add filename (without path) to identities array. + identities+=("${file##*/}") + fi done fi -- cgit v1.2.3-70-g09d2 From 09a94672003b21b8a3d8d15d31098641e7f3a4db Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 15 Oct 2024 13:02:12 +0200 Subject: Revert "feat(ssh-agent): add keys regardless of filename (#12741)" (#12761) This reverts commit d2d5155d41cbe183ef172fef1e83a29d116a5af6. Closes #12743 Closes #12745 Closes #12758 --- plugins/ssh-agent/ssh-agent.plugin.zsh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'plugins/ssh-agent/ssh-agent.plugin.zsh') diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index becd5ea17..83548648b 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -39,16 +39,13 @@ function _add_identities() { return fi - # If no keys specified in zstyle, add default keys. - # Mimics calling ssh-add with no arguments. - if [[ ${#identities[@]} -eq 0 ]]; then - # Iterate over files in .ssh folder. - for file in "$HOME/.ssh"/*; do - # Check if file is a regular file and starts with "-----BEGIN OPENSSH PRIVATE KEY-----". - if [[ -f "$file" && $(command head -n 1 "$file") =~ ^-----BEGIN\ OPENSSH\ PRIVATE\ KEY----- ]]; then - # Add filename (without path) to identities array. - identities+=("${file##*/}") - fi + # add default keys if no identities were set up via zstyle + # this is to mimic the call to ssh-add with no identities + if [[ ${#identities} -eq 0 ]]; then + # key list found on `ssh-add` man page's DESCRIPTION section + for id in id_rsa id_dsa id_ecdsa id_ed25519 id_ed25519_sk identity; do + # check if file exists + [[ -f "$HOME/.ssh/$id" ]] && identities+=($id) done fi -- cgit v1.2.3-70-g09d2