non ancora funzionante

This commit is contained in:
Marco Raber 2021-10-28 16:02:13 +02:00
commit ee82adfb57
3 changed files with 19 additions and 0 deletions

1
port_association Normal file
View File

@ -0,0 +1 @@
octosrv.me 2323

3
setup.sh Normal file
View File

@ -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/"

15
sshin Executable file
View File

@ -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