Script Distribution via SCP
If all systems are accessible via SSH, SCP is a decent option for distributing and collecting data. The example below makes a few assumptions:
- You’re using a non-root user named user. In the example, we’re going to use user@ everywhere, but if you’re already using a user named that you won’t need it. sudo is available for becoming root
- The machine in Xylok was named “my_machine”
- Using the domain name my_machine can access the machine. If this isn’t true, use the correct name and/or IP address.
- Your terminal is open and inside the base of the CD image (ISO) root. I.E., you downloaded the script ISO from Xylok and put the contents in
~/xylok
and now running pwd shows~/xylok
.
# The lines starting with pound signs are comments
# Make a place to store the results (only need to do this once)
mkdir -p results/
# Copy script folder to user's home directory on the target machine
scp -r my_machine/ user@my_machine:
# Run script
ssh user@my_machine sudo my_machine/xylok_collect.sh
# Copy data back
scp user@my_machine:my_machine/*.results results/
# Clean up target machine
ssh user@my_machine sudo rm -r my_machine/
Repeat this process for every machine. At the end, all the result files will be stored on the local machine in the results/ folder
If SSH times out before the script can complete, you can run the script using nohup so it will continue to run in the background.
ssh -t user@my_machine -- 'nohup sudo sh my_machine/xylok-collect.sh >script-log.txt 2>&1 </dev/null &'
ssh user@my_machine -- tail -f script-log.txt