diff --git a/port_association b/port_association index 089966e..6c91d73 100644 --- a/port_association +++ b/port_association @@ -1 +1 @@ -octosrv.me 2323 +example.com 2323 diff --git a/sshin b/sshin index d08c666..9f78a34 100755 --- a/sshin +++ b/sshin @@ -1,7 +1,11 @@ #!/bin/bash usage() { - [[ $# -le 1 ]] && echo "Usage: sshin user hostname/last byte of IP address" && echo "sshin -h for more information" || echo "Optional parameters: custom server port" && echo "Example: \"sshin foo bar.com \" will run \"ssh foo@bar.com -p 2323\"" + echo "Usage: sshin user hostname/last byte of IP address" + echo + echo "This tools automatically chooses the server port based on the port_association file in ~/local/share/sshin/port_association" + echo + echo "Example: \"sshin foo bar.com \" will run \"ssh foo@bar.com -p 2323\"" return } @@ -11,5 +15,12 @@ IP_PREFIX="192.168.1." re='^[0-9]+$' command="ssh ${1}@" shift -[[ $1 =~ $re ]] && command="${command}192.168.1.$2" || port=$(grep ~/.local/share/sshin/port_association $1 | awk '{print $NF}') && command="${command}$1 -p $port" -echo $command +#[[ $1 =~ $re ]] && command="${command}192.168.1.$2" || port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') && command="${command}$1 -p $port" +if [[ $1 =~ $re ]] +then + command="${command}192.168.1.$1" +else + port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') && command="${command}$1 -p $port" +fi +#echo $command +$command