add scripts from dmzscripts repo to scripts
This commit is contained in:
49
scripts/ctcreate/ctcreate.sh
Executable file
49
scripts/ctcreate/ctcreate.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
## Create new Linux contanier at a proxmox host
|
||||
|
||||
DMZKEYFILE="~/.ssh/dmz"
|
||||
|
||||
PROXMOXHOST=$1
|
||||
CTHOST=$2
|
||||
|
||||
GENPASS=$( echo $(shuf ../shared/english.txt | head) | sed "s/ //g")
|
||||
|
||||
if [[ -z "$PROXMOXHOST" ]]; then
|
||||
echo "Set Proxmox Host"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$CTHOST" ]]; then
|
||||
echo "Set CT hostname"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$GENPASS" ]]; then
|
||||
echo "Set CT password"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh-add -t 200 $DMZKEYFILE
|
||||
torsocks scp ./remotecmd $PROXMOXHOST:/root/ctcreate.sh
|
||||
|
||||
torsocks ssh $PROXMOXHOST "chmod +x /root/ctcreate.sh; /root/ctcreate.sh $CTHOST $GENPASS" >> cmdoutput.txt
|
||||
|
||||
CREDS=$( tail -3 cmdoutput.txt)
|
||||
|
||||
rm cmdoutput.txt
|
||||
|
||||
printf "$CREDS\n" | gpg -e -r fram3d@dmz.rs -r sienna@dmz.rs --output ~/src/dmzadmin/credentials/krov/$CTHOST.gpg
|
||||
|
||||
CTIP=$(printf "$CREDS" | head -1 | cut -d'@' -f 2)
|
||||
|
||||
echo Host dmzkrov$CTHOST >> ~/.ssh/autoconfig
|
||||
echo " Hostname" $CTIP >> ~/.ssh/autoconfig
|
||||
echo " ProxyJump" dmzkrovtor12 >> ~/.ssh/autoconfig
|
||||
echo " User" root >> ~/.ssh/autoconfig
|
||||
echo " IdentityFile" /home/anon/.ssh/krov/tor11 >> ~/.ssh/autoconfig
|
||||
echo " PasswordAuthentication" no >> ~/.ssh/autoconfig
|
||||
|
||||
ssh -R $CTIP
|
||||
torsocks scp ./newct dmzkrov$CTHOST:/root/newct.sh
|
||||
torsocks ssh dmzkrov$CTHOST "bash newct.sh; rm newct.sh"
|
||||
torsocks ssh dmzkrov$CTHOST
|
Reference in New Issue
Block a user