From ee82adfb57f81f68648ecedc40bbb730ee959421 Mon Sep 17 00:00:00 2001 From: Marco Raber Date: Thu, 28 Oct 2021 16:02:13 +0200 Subject: [PATCH] non ancora funzionante --- port_association | 1 + setup.sh | 3 +++ sshin | 15 +++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 port_association create mode 100644 setup.sh create mode 100755 sshin diff --git a/port_association b/port_association new file mode 100644 index 0000000..089966e --- /dev/null +++ b/port_association @@ -0,0 +1 @@ +octosrv.me 2323 diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..7903354 --- /dev/null +++ b/setup.sh @@ -0,0 +1,3 @@ +mkdir ~/.local/share/sshin +cp port_association ~/.local/share/sshin/ +cp sshin ~/.local/bin || echo "Error in copying executable to .local/bin" && echo "Run: sudo cp sshin /usr/bin/" diff --git a/sshin b/sshin new file mode 100755 index 0000000..d08c666 --- /dev/null +++ b/sshin @@ -0,0 +1,15 @@ +#!/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\"" + return +} + +IP_PREFIX="192.168.1." +[[ $# -le 1 ]] && usage && exit 1 +[[ $1 = "-h" ]] && usage -h && exit 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