This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
computing:remote-upgrades [2019/04/21 07:13] – oemb1905 | computing:remote-upgrades [2020/01/27 20:42] (current) – oemb1905 | ||
---|---|---|---|
Line 11: | Line 11: | ||
------------------------------------------- | ------------------------------------------- | ||
- | Ok, I was looking for an easy secure way to remotely upgrade the servers I manage all at once from my primary | + | For remote upgrades |
sudo touch / | sudo touch / | ||
Line 18: | Line 18: | ||
sudo nano / | sudo nano / | ||
| | ||
- | Enter your desired updating and upgrading parameters. | + | Once that is done, put in some parameters |
- | + | ||
#!/bin/bash | #!/bin/bash | ||
- | apt update | + | |
+ | cat /etc/motd | ||
+ | | ||
+ | | ||
+ | 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 the sudoers | + | Edit sudoers |
sudo nano / | sudo nano / | ||
Add the following to the file, obviously changing " | Add the following to the file, obviously changing " | ||
- | + | | |
username ALL=(root) NOPASSWD: / | username ALL=(root) NOPASSWD: / | ||
- | + | | |
- | Once this is set up, reboot each remote target, and now switch | + | Now you are ready to create the script on the primary workstation |
sudo touch / | sudo touch / | ||
Line 41: | Line 57: | ||
| | ||
#!/bin/bash | #!/bin/bash | ||
- | | + | |
#run on each host | #run on each host | ||
- | for i in $hostsa; | + | for i in $hosts; |
do | do | ||
- | echo $i; | + | echo "I will now update" |
- | ssh -t -p 60000 $i sudo apt-remote; | + | |
- | done; | + | ssh -t $i screen -S aptremotescreen |
- | #use another set up if the targets have different ssh configs, etc. | + | |
- | hostsb=" | + | |
- | #run on each host | + | |
- | for i in $hostsb; | + | |
- | do | + | |
- | echo $i; | + | |
- | ssh -t -p 222 $i sudo apt-remote; | + | |
done; | done; | ||
- | When you test it, there should be no password prompts to connect to the remote hosts as the sudoer entry on the targets ensure that will not happen. | + | If you would prefer |
- | # | + | Option 1 - Using vpn connection, connect from localhost to remote host/server with ssh and screen, and then execute a script on the server that uses rsync over ssh to send its backup to target backup host on its LAN: |
- | #cd / | + | |
- | #sudo openvpn vizcarraguitars.mooo.com.ovpn --daemon | + | |
- | cd / | + | |
- | sudo openvpn vizcarraguitars.mooo.com.ovpn & | + | |
- | sleep 10s | + | |
- | #update hosts remotely using ssh | + | |
- | hostsa=" | + | |
- | for i in $hostsa; | + | |
- | do | + | |
- | echo "I will now update" | + | |
- | | + | |
- | done; | + | |
- | #finish the script | + | |
- | cd ~ | + | |
- | sudo killall openvpn | + | |
- | sleep 10s | + | |
- | --- //[[netcmnd@jonathanhaack.com|oemb1905]] | + | Use this script on your localhost: [[https:// |
+ | Use this script on the remote host that you are backing up: [[https:// | ||
+ | |||
+ | Option 2 - Using vpn connection, connect from localhost to remote host/server with ssh and screen, and then execute a script on the server that uses rsync over ssh to send its backup back to you at localhost: | ||
+ | |||
+ | Use this script on your localhost: [[https:// | ||
+ | |||
+ | --- //[[jonathan@haacksnetworking.com|oemb1905]] |