Skip to content

Instantly share code, notes, and snippets.

@srkiNZ84
Created May 17, 2018 10:21
Show Gist options
  • Save srkiNZ84/48c73aac3ff0ee4f40f25c7b6db11a21 to your computer and use it in GitHub Desktop.
Save srkiNZ84/48c73aac3ff0ee4f40f25c7b6db11a21 to your computer and use it in GitHub Desktop.
SSH onto servers and grab logs from nginx
#!/bin/bash
WEBSERVERS=( 12.3.4.5
54.111.111.111 \
54.222.222.222 )
SSHKEYFILE=.ssh/server.key
for SERVER in ${WEBSERVERS[@]}; do
echo "Server is $SERVER"
mkdir -p web_${SERVER}
ssh -i ${SSHKEYFILE} ubuntu@${SERVER} sudo usermod -a -G www-data ubuntu
scp -i ${SSHKEYFILE} ubuntu@${SERVER}:/var/log/nginx/* web_${SERVER}/
scp -i ${SSHKEYFILE} ubuntu@${SERVER}:/var/log/nginx/* web_${SERVER}/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment