fix scripts

This commit is contained in:
fram3d 2024-02-13 01:36:11 +01:00
parent 2e62c1b33b
commit 4b272c2929
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
3 changed files with 19 additions and 10 deletions

View File

@ -2,6 +2,8 @@
## Create new Linux contanier at a proxmox host ## Create new Linux contanier at a proxmox host
DMZKEYFILE=$(echo -n ~)"/.ssh/dmz" DMZKEYFILE=$(echo -n ~)"/.ssh/dmz"
USER=$(cut -d" " -f3 $DMZKEYFILE.pub | cut -d "@" -f1)
USEREMAIL=$(cut -d" " -f3 $DMZKEYFILE.pub)
PROXMOXHOST=$1 PROXMOXHOST=$1
CTHOST=$2 CTHOST=$2
@ -23,25 +25,26 @@ if [[ -z "$GENPASS" ]]; then
exit 1 exit 1
fi fi
ssh-add -t 200 $DMZKEYFILE ssh-add -t 600 $DMZKEYFILE
torsocks scp ./remotecmd $PROXMOXHOST:/root/ctcreate.sh torsocks scp ./remotecmd $PROXMOXHOST:/root/ctcreate.sh
torsocks scp $DMZKEYFILE.pub $PROXMOXHOST:/root/.ssh/$USER.pub
torsocks ssh $PROXMOXHOST "chmod +x /root/ctcreate.sh; /root/ctcreate.sh $CTHOST $GENPASS" >> cmdoutput.txt torsocks ssh $PROXMOXHOST "chmod +x /root/ctcreate.sh; /root/ctcreate.sh $CTHOST $GENPASS $USER" >> cmdoutput.txt
CREDS=$( tail -3 cmdoutput.txt) CREDS=$( tail -3 cmdoutput.txt)
rm 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 printf "$CREDS\n" | gpg -e -r $USEREMAIL --output $CTHOST.gpg
CTIP=$(printf "$CREDS" | head -1 | cut -d'@' -f 2) CTIP=$(printf "$CREDS" | head -1 | cut -d'@' -f 2)
echo Host dmzkrov$CTHOST >> ~/.ssh/autoconfig echo "Host dmzkrov"$CTHOST >> ~/.ssh/autoconfig
echo " Hostname "$CTIP >> ~/.ssh/autoconfig echo " Hostname "$CTIP >> ~/.ssh/autoconfig
echo " ProxyJump" dmzkrovtor12 >> ~/.ssh/autoconfig echo " ProxyJump dmzkrovtor12" >> ~/.ssh/autoconfig
echo " User" root >> ~/.ssh/autoconfig echo " User root" >> ~/.ssh/autoconfig
echo " IdentityFile" /home/anon/.ssh/krov/tor11 >> ~/.ssh/autoconfig echo " IdentityFile "$DMZKEYFILE >> ~/.ssh/autoconfig
echo " PasswordAuthentication" no >> ~/.ssh/autoconfig echo " PasswordAuthentication no" >> ~/.ssh/autoconfig
ssh -R $CTIP ssh -R $CTIP
torsocks scp ./newct dmzkrov$CTHOST:/root/newct.sh torsocks scp ./newct dmzkrov$CTHOST:/root/newct.sh

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
apt update apt update
apt -y dist-upgrade apt -y dist-upgrade
apt install unattended-upgrades apt -y install unattended-upgrades
dpkg-reconfigure unattended-upgrades dpkg-reconfigure unattended-upgrades

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
CTHOSTNAME=$1 CTHOSTNAME=$1
CTPASS=$2 CTPASS=$2
USER=$3
echo Creating $CTHOSTNAME ... echo Creating $CTHOSTNAME ...
@ -17,6 +18,11 @@ if [[ -z "$CTPASS" ]]; then
exit 1 exit 1
fi fi
if [[ -z "$USER" ]]; then
echo "USER not set"
exit 1
fi
if [[ -z "$LASTID" ]]; then if [[ -z "$LASTID" ]]; then
LASTID=99 LASTID=99
fi fi