Import workaround to configure hosts with non-standard SSH port
This commit is contained in:
parent
6e2130b305
commit
afa6b31844
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Workaround to configure hosts with SSH servers listening on non-standard
|
||||
# ports (e.g. IPv4-only VMs hidden behind a NAT). It'll blow up with IPv6
|
||||
# addresses and might burn your house.
|
||||
|
||||
set -x
|
||||
|
||||
target_host=$(echo "$@" | rev | cut -d ' ' -f1 | rev)
|
||||
args=$(echo "$@" | rev | cut -d ' ' -f1 --complement | rev)
|
||||
|
||||
name=$(echo $target_host | cut -d ':' -f 1)
|
||||
port_or_path=$(echo $target_host | cut -d ':' -f 2)
|
||||
path=$(echo $target_host | cut -d ':' -f 3)
|
||||
|
||||
addr=$name:$port_or_path
|
||||
scp_extra_params=
|
||||
if [ -n "$path" ]; then
|
||||
addr=$name:$path
|
||||
scp_extra_params="-P $port_or_path"
|
||||
fi
|
||||
|
||||
scp -o User=root -q $scp_extra_params $args $addr
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Workaround to configure hosts with SSH servers listening on non-standard
|
||||
# ports (e.g. IPv4-only VMs hidden behind a NAT). It'll blow up with IPv6
|
||||
# addresses and might burn your house.
|
||||
|
||||
target_host=$1; shift
|
||||
name=$(echo $target_host | cut -d ':' -f 1)
|
||||
port=$(echo $target_host | cut -d ':' -s -f 2)
|
||||
|
||||
ssh_extra_params=
|
||||
if [ -n "$port" ]; then
|
||||
ssh_extra_params="-p $port"
|
||||
fi
|
||||
|
||||
ssh -o User=root $ssh_extra_params $name $@
|
Loading…
Reference in New Issue