This is an old revision of the document!
remote-upgrades
For remote upgrades from primary workstation, first create a file on target called apt-remote:
sudo touch /usr/local/bin/apt-remote sudo chmod 750 /usr/local/bin/apt-remote sudo chown $USER:$USER /usr/local/bin/apt-remote sudo nano /usr/local/bin/apt-remote
Once that is done, put in some parameters that will provide nice feedback to you while you execute the command from primary workstation:
#!/bin/bash echo "I am beginning"; cat /etc/motd apt update apt dist-upgrade apt autoremove apt autoclean echo "I just finished"; echo "----->" echo "-----> ----->" echo "-----> -----> ----->" echo "-----> -----> -----> ----->" echo "-----> -----> -----> -----> -----> ... ... " hostname date uname -a echo "If there is another, I will begin that now ..."; sleep 10s
Edit sudoers so that this command can be run on target without password, (or, if your prefer, do not do this, and then you can enter the password for each target as the primary workstations script executes):
sudo nano /etc/sudoers
Add the following to the file, obviously changing “username” to the target machine's user name.
username ALL=(root) NOPASSWD: /usr/local/bin/apt-remote
Now you are ready to create the script on the primary workstation that will pass the apt-remote script to the target workstations:
sudo touch /usr/local/bin/apt-remote-update.sh sudo chmod 750 /usr/local/bin/apt-remote-update.sh sudo chown $USER:$USER /usr/local/bin/apt-remote-update.sh sudo touch /usr/local/bin/apt-remote-update.sh
In the file that opens, use the following script parameters or something similar. This script runs on the primary workstation and then executes the “sudo apt-remote” script on the target machine. Again, none of this will work if your ssh is improperly configured.
hostsa=“haackremote.mooo.com lthsf.mooo.com” #run on each host for i in $hostsa; do
echo "I will now update" $i; ssh -t -p 60000 $i sudo apt-remote;
done;
And here is how I adjusted the primary workstation script to do this with a remote host that requires an openvpn connection to be established first:
#!/bin/bash cd /home/wsuser/zion/client-recs/client/vpn-client-name sudo openvpn hostname.mooo.com.ovpn & sleep 10s hostsa="10.44.44.19 10.44.44.85" for i in $hostsa; do echo "I will now update" $i; ssh -t -p 59999 targetuser@$i sudo apt-remote; done; cd ~ sudo killall openvpn sleep 10s
These configs an be found on the haackingclub gitlab repository over here:
— oemb1905 2020/01/20 21:59