cdist-workdir/remote-exec-custom-port.sh

17 lines
434 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.
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 $@