add onionadd script
This commit is contained in:
parent
4b272c2929
commit
da563fd8be
1
scripts/onionadd/cmdoutput.txt
Normal file
1
scripts/onionadd/cmdoutput.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
j3kztfnedlfhikhr7uro7uxzf35xbrtcu4omzbl2bqb6ygakipcw62yd.onion
|
36
scripts/onionadd/onionadd.sh
Executable file
36
scripts/onionadd/onionadd.sh
Executable 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
|
23
scripts/onionadd/remotecmd
Normal file
23
scripts/onionadd/remotecmd
Normal 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"
|
Loading…
Reference in New Issue
Block a user