Created
May 17, 2018 10:21
-
-
Save srkiNZ84/48c73aac3ff0ee4f40f25c7b6db11a21 to your computer and use it in GitHub Desktop.
SSH onto servers and grab logs from nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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