diff --git a/scripts/onionadd/cmdoutput.txt b/scripts/onionadd/cmdoutput.txt new file mode 100644 index 0000000..e52982e --- /dev/null +++ b/scripts/onionadd/cmdoutput.txt @@ -0,0 +1 @@ +j3kztfnedlfhikhr7uro7uxzf35xbrtcu4omzbl2bqb6ygakipcw62yd.onion diff --git a/scripts/onionadd/onionadd.sh b/scripts/onionadd/onionadd.sh new file mode 100755 index 0000000..2d09463 --- /dev/null +++ b/scripts/onionadd/onionadd.sh @@ -0,0 +1,36 @@ +#!/bin/bash +## Create new Linux contanier at a proxmox host + +DMZKEYFILE=$(echo -n ~)"/.ssh/dmz" + +TORHOST=$1 +CTHOST=$2 +CTIP=$3 + +if [[ -z "$TORHOST" ]]; then + echo "Set Tor Host" + exit 1 +fi + +if [[ -z "$CTHOST" ]]; then + echo "Set CT hostname" + exit 1 +fi + +if [[ -z "$CTIP" ]]; then + CTIP=$(grep -C 1 $CTHOST ~/.ssh/autoconfig | tail -1 | cut -d" " -f4) +fi + +ssh-add -t 600 $DMZKEYFILE +torsocks scp ./remotecmd $TORHOST:/root/onionadd.sh + +torsocks ssh $TORHOST "chmod +x /root/onionadd.sh; /root/onionadd.sh $CTHOST $CTIP" >> cmdoutput.txt +torsocks ssh $TORHOST "rm /root/onionadd.sh" + +HOSTNAME=$(tail -1 cmdoutput.txt) + +echo "Host "$CTHOST"onion" >> ~/.ssh/autoconfig +echo " Hostname "$HOSTNAME >> ~/.ssh/autoconfig +echo " User root" >> ~/.ssh/autoconfig +echo " IdentityFile "$DMZKEYFILE >> ~/.ssh/autoconfig +echo " PasswordAuthentication no" >> ~/.ssh/autoconfig diff --git a/scripts/onionadd/remotecmd b/scripts/onionadd/remotecmd new file mode 100644 index 0000000..282cee2 --- /dev/null +++ b/scripts/onionadd/remotecmd @@ -0,0 +1,23 @@ +#!/bin/bash + +CTHOST=$1 +CTIP=$2 + +if [[ -z "$CTHOST" ]]; then + echo "Set CT hostname" + exit 1 +fi + +if [[ -z "$CTIP" ]]; then + echo "Set CT IP" + exit 1 +fi + +echo "" >> /etc/tor/onions/dmz +echo "HiddenServiceDir /var/lib/tor/"$CTHOST"/" >> /etc/tor/onions/dmz +echo "HiddenServicePort 22 "$CTIP":22" >> /etc/tor/onions/dmz + +service tor reload +sleep 30 + +cat "/var/lib/tor/"$CTHOST"/hostname"