2018-06-05 15:24:58 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-06-05 16:50:25 -04:00
|
|
|
dir=/opt/sshjump
|
|
|
|
|
2018-06-05 15:24:58 -04:00
|
|
|
arg1=$1
|
|
|
|
|
|
|
|
if [ $arg1 = list ]; then
|
2018-06-05 16:50:25 -04:00
|
|
|
sqlite3 $dir/sshjump.db 'select host,id from sshjump'
|
2018-06-05 15:24:58 -04:00
|
|
|
|
2018-06-05 16:41:01 -04:00
|
|
|
elif [ $arg1 = host ]; then
|
2018-06-05 15:24:58 -04:00
|
|
|
user=$2
|
|
|
|
host=$3
|
2018-06-05 16:50:25 -04:00
|
|
|
port=$(sqlite3 $dir/sshjump.db "select port from sshjump where host = \"$host\"")
|
2018-06-05 15:24:58 -04:00
|
|
|
ssh -p $port $user@localhost
|
|
|
|
|
2018-06-05 16:41:01 -04:00
|
|
|
elif [ $arg1 = id ]; then
|
2018-06-05 15:24:58 -04:00
|
|
|
user=$2
|
|
|
|
id=$3
|
2018-06-05 16:50:25 -04:00
|
|
|
port=$(sqlite3 $dir/sshjump.db "select port from sshjump where id = \"$id\"")
|
2018-06-05 15:24:58 -04:00
|
|
|
ssh -p $port $user@localhost
|
2018-06-05 16:41:01 -04:00
|
|
|
|
|
|
|
elif [ $arg1 = del ]; then
|
|
|
|
id=$2
|
2018-06-05 16:50:25 -04:00
|
|
|
sqlite3 $dir/sshjump.db "delete from sshjump where id = \"$id\""
|
2018-06-05 16:41:01 -04:00
|
|
|
|
2018-06-06 06:49:43 -04:00
|
|
|
else
|
2018-06-05 16:41:01 -04:00
|
|
|
echo "list: show list of devices"
|
|
|
|
echo "host username device"
|
|
|
|
echo "id username deviceID"
|
|
|
|
echo "del deviceID"
|
2018-06-05 15:24:58 -04:00
|
|
|
fi
|