aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Ramos2024-01-16 13:04:39 +0100
committerGuillermo Ramos2024-01-16 13:06:04 +0100
commit7533fdb5ed76185176291e9d4ed7c3735d7a0a17 (patch)
tree9d07f6b5a472635b78bd6f13d5f9150a147ff7be
parentedcefbc5f0aae055da1ea83223764e18b3ed4033 (diff)
downloadcli-7533fdb5ed76185176291e9d4ed7c3735d7a0a17.tar.gz
passh / ssf: some improvements
-rwxr-xr-xpassh9
-rwxr-xr-xssf8
2 files changed, 13 insertions, 4 deletions
diff --git a/passh b/passh
index 765c0c9..092e124 100755
--- a/passh
+++ b/passh
@@ -13,17 +13,22 @@ rm "$pipe" # remove file
echo -n "Trying to get password from 'pass'... "
if pass show "${PASS_PREFIX}$host" 2> /dev/null >&3; then
echo "FOUND ('${PASS_PREFIX}$host'). Connecting..."
- exec sshpass -d3 ssh -o StrictHostKeyChecking=accept-new $@
+ set -x
+ exec sshpass -d3 ssh -v -o StrictHostKeyChecking=accept-new $@
else
echo "not found. Trying pubkeys..."
- ssh -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=accept-new $@
+ set -x
+ ssh -o NumberOfPasswordPrompts=0 -v -o StrictHostKeyChecking=accept-new $@
ok=$?
+ set +x
if [ "$ok" -ne 0 ]; then
read -rp "Connection via pubkey failed, password? " passphrase
echo "$passphrase" >&3
echo "Connecting with passphrase..."
+ set -x
sshpass -d3 ssh -o StrictHostKeyChecking=accept-new $@
ok=$?
+ set +x
if [ "$ok" -eq 0 ]; then
echo "It worked! Storing password..."
echo "$passphrase" | pass insert -e "${PASS_PREFIX}$host"
diff --git a/ssf b/ssf
index 6df0c63..a0d64d0 100755
--- a/ssf
+++ b/ssf
@@ -29,7 +29,11 @@ foreach my $cfgfile (glob "$ENV{HOME}/.ssh/config.d/*") {
}
next unless defined $key;
if ($key eq 'Host') {
- @line_hosts = map { { _pat => $_ } } (split /\s/, $value);
+ if ($value =~ /"/) {
+ @line_hosts = ({ _pat => $value });
+ } else {
+ @line_hosts = map { { _pat => $_ } } (split /\s/, $value);
+ }
push @hosts, @line_hosts;
} elsif ($key eq 'Match') {
@line_hosts = ();
@@ -82,5 +86,5 @@ if (exists $ENV{TMUX}) {
system 'passh', $hostname, '-t', "sh -c \"tmux new -As $remote_session_name\"";
`tmux rename-window '[$hostname]'`;
} else {
- exec 'passh', $hostname, '-t', "sh -c \"tmux new -As $remote_session_name\"";
+ exec 'passh', $hostname;
}