From 200ed58973cf002afa7fc0f98610009cd87ba3ea Mon Sep 17 00:00:00 2001 From: 12nick12 Date: Tue, 5 Jun 2018 15:32:51 -0400 Subject: [PATCH] Create setup.sh --- host/setup.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 host/setup.sh diff --git a/host/setup.sh b/host/setup.sh new file mode 100644 index 0000000..0345010 --- /dev/null +++ b/host/setup.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +host=$(hostname) +ip=$(curl -s https://canihazip.com/s) +port=$(shuf -i 9151-49151 -n 1) +id=$(shuf -i 111111111-999999999 -n 1 ) +dir=/opt/sshjump + +mkdir $dir + +ssh-keygen -t rsa -f $dir/id_rsa -q -N "" + +chmod 400 $dir/id_rsa* + +cat $dir/id_rsa.pub | ssh -p port root@remotehost.com "mkdir -p ~/.ssh; chmod 700 ~/.ssh; cat >> ~/.ssh/authorized_keys" + +sqlite3 $dir/sshjump.db 'create table sshjump(host, ip, port, id);' + +sqlite3 $dir/sshjump.db "INSERT INTO sshjump(host, ip, port, id) VALUES(\"$host\", \"$ip\", \"$port\", \"$id\");" + +echo "INSERT INTO sshjump(host, ip, port, id) VALUES(\"$host\", \"$ip\", \"$port\", \"$id\");" | ssh -p 22333 root@remotessh.nicks.tv "sqlite3 /opt/sshjump/sshjump.db"