add onionadd script

This commit is contained in:
fram3d 2024-02-13 03:08:27 +01:00
parent 4b272c2929
commit da563fd8be
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1 @@
j3kztfnedlfhikhr7uro7uxzf35xbrtcu4omzbl2bqb6ygakipcw62yd.onion

36
scripts/onionadd/onionadd.sh Executable file
View File

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

View File

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