Skip to content

Commit

Permalink
Fold ssh_with_forwarding command into ssh command
Browse files Browse the repository at this point in the history
  • Loading branch information
koverstreet committed Nov 17, 2020
1 parent 50e7a5b commit be16039
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions lib/libktest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ parse_ktest_arg()
x)
set -x
;;
f)
ktest_ssh_port=$OPTARG
f)
ktest_ssh_port=$OPTARG
;;
esac
}

Expand Down Expand Up @@ -183,37 +184,29 @@ ktest_boot()

ktest_ssh()
{
sock=$ktest_vmdir/net
ip="10.0.2.2"

(cd "$ktest_dir/lib"; make lwip-connect) > /dev/null

exec ssh -t -F /dev/null \
-o CheckHostIP=no \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o NoHostAuthenticationForLocalhost=yes \
-o ServerAliveInterval=2 \
-o ControlMaster=auto \
-o ControlPath="$ktest_vmdir/controlmaster" \
-o ControlPersist=yes \
-o ProxyCommand="$ktest_dir/lib/lwip-connect $sock $ip 22" \
[email protected] "$@"
}
local ssh_cmd=(ssh -t -F /dev/null \
-o CheckHostIP=no \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o NoHostAuthenticationForLocalhost=yes \
-o ServerAliveInterval=2 \
-o ControlMaster=auto \
-o ControlPath="$ktest_vmdir/controlmaster" \
-o ControlPersist=yes \
)

if [[ $ktest_ssh_port = 0 ]]; then
sock=$ktest_vmdir/net
ip="10.0.2.2"

(cd "$ktest_dir/lib"; make lwip-connect) > /dev/null

ssh_cmd+=(-o ProxyCommand="$ktest_dir/lib/lwip-connect $sock $ip 22")
else
ssh_cmd+=(-p $ktest_ssh_port)
fi

ktest_ssh_with_forwarding()
{
exec ssh -t -F /dev/null \
-o CheckHostIP=no \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o NoHostAuthenticationForLocalhost=yes \
-o ServerAliveInterval=2 \
-o ControlMaster=auto \
-o ControlPath="$ktest_vmdir/controlmaster" \
-o ControlPersist=yes \
-p $ktest_ssh_port \
[email protected] "$@"
exec "${ssh_cmd[@]}" [email protected] "$@"
}

ktest_gdb()
Expand Down

0 comments on commit be16039

Please sign in to comment.