24 lines
641 B
Bash
Executable File
24 lines
641 B
Bash
Executable File
#!/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
|