From 004843feb82f3e48dda3af7fd0620243cb28ac18 Mon Sep 17 00:00:00 2001 From: Tsogoo Date: Mon, 17 Jan 2022 14:13:18 +0800 Subject: [PATCH 1/5] if ssh address is not present, make one from user and IP --- ssh.bash | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/ssh.bash b/ssh.bash index 435c4c2..825e871 100755 --- a/ssh.bash +++ b/ssh.bash @@ -15,15 +15,28 @@ ssh_read_data() { read -r ssh_password < <(echo "$contents") while read -r line; do - if [[ "$line" == ssh:* ]]; then - local ssh_address=${line#"ssh:"} - ssh_address=${ssh_address##+([[:space:]])} - fi - if [[ "$line" == sshflags:* ]]; then - local ssh_flags=${line#"sshflags:"} - ssh_flags=${ssh_flags##+([[:space:]])} - fi + if [[ "$line" == ssh:* ]]; then + local ssh_address=${line#"ssh:"} + ssh_address=${ssh_address##+([[:space:]])} + fi + if [[ "$line" == sshflags:* ]]; then + local ssh_flags=${line#"sshflags:"} + ssh_flags=${ssh_flags##+([[:space:]])} + fi + if [[ "$line" == user:* ]]; then + local ssh_user=${line#"user:"} +# ssh_user=${ssh_user##+([[:space::]])} + fi + if [[ "$line": == IP:* ]]; then + local ssh_host=${line#"IP:"} +# ssh_host=${ssh_host##+([[:space::]])} + fi done < <(echo "$contents") + if [[ -z ${ssh_address+x} ]]; then + ssh_address="${ssh_user// /}@${ssh_host// /}" + echo "$ssh_address" + fi + [[ -z ${ssh_address+x} ]] && die "$path: SSH host not defined." # Default value for flags ssh_flags="${ssh_flags:-}" @@ -32,4 +45,4 @@ ssh_read_data() { /usr/bin/sshpass -e -- ssh $ssh_flags "${@:2}" "$ssh_address" } -ssh_read_data "$@" \ No newline at end of file +ssh_read_data "$@" From fd5735466230b16c96dd58100150c923e5d64a6e Mon Sep 17 00:00:00 2001 From: Tsogoo Date: Mon, 17 Jan 2022 15:39:36 +0800 Subject: [PATCH 2/5] removed echo for debugging --- ssh.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/ssh.bash b/ssh.bash index 825e871..9c616c2 100755 --- a/ssh.bash +++ b/ssh.bash @@ -34,7 +34,6 @@ ssh_read_data() { done < <(echo "$contents") if [[ -z ${ssh_address+x} ]]; then ssh_address="${ssh_user// /}@${ssh_host// /}" - echo "$ssh_address" fi [[ -z ${ssh_address+x} ]] && die "$path: SSH host not defined." From 4f6039ccd19343f53a6abe17da397d83774b1533 Mon Sep 17 00:00:00 2001 From: Tsogtbileg Dash-Yondon Date: Mon, 17 Jan 2022 18:35:49 +0800 Subject: [PATCH 3/5] Readme change --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5376b56..68549c2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +This is a fork of https://github.com/not-jan/pass-ssh + # pass-ssh Allows you to start an SSH session from a pass entry. @@ -20,4 +22,4 @@ Drop ssh.bash into `/usr/lib/password-store/extensions` (distro specific) or `~/ > sshflags: -q -D 1337 > ``` 2. Run `pass ssh ` -3. You will be dropped into the requested ssh shell \ No newline at end of file +3. You will be dropped into the requested ssh shell From 007916ed3375796f10145e6d54033d31485274e2 Mon Sep 17 00:00:00 2001 From: Tsogtbileg Dash-Yondon Date: Mon, 31 Jan 2022 15:19:06 +0800 Subject: [PATCH 4/5] Revert "Readme change" This reverts commit 4f6039ccd19343f53a6abe17da397d83774b1533. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 68549c2..5376b56 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -This is a fork of https://github.com/not-jan/pass-ssh - # pass-ssh Allows you to start an SSH session from a pass entry. @@ -22,4 +20,4 @@ Drop ssh.bash into `/usr/lib/password-store/extensions` (distro specific) or `~/ > sshflags: -q -D 1337 > ``` 2. Run `pass ssh ` -3. You will be dropped into the requested ssh shell +3. You will be dropped into the requested ssh shell \ No newline at end of file From 03ce76ddf3e917fd4500b8ca845b91898b376e88 Mon Sep 17 00:00:00 2001 From: Tsogtbileg Dash-Yondon Date: Mon, 31 Jan 2022 15:31:28 +0800 Subject: [PATCH 5/5] Sometimes the shell behaves oddly when using kitty to ssh into a server. This is a workaround --- ssh.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ssh.bash b/ssh.bash index 9c616c2..e0afe7a 100755 --- a/ssh.bash +++ b/ssh.bash @@ -40,6 +40,9 @@ ssh_read_data() { # Default value for flags ssh_flags="${ssh_flags:-}" + if [[ "$TERM" == "xterm-kitty" ]]; then + export TERM="xterm-color" + fi export SSHPASS="$ssh_password" /usr/bin/sshpass -e -- ssh $ssh_flags "${@:2}" "$ssh_address" }