Skip to content

Instantly share code, notes, and snippets.

@kclosu
Created November 1, 2018 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kclosu/9c580f003656fdf69ea8a67129b9c10c to your computer and use it in GitHub Desktop.
Save kclosu/9c580f003656fdf69ea8a67129b9c10c to your computer and use it in GitHub Desktop.
Add line to end of file with sudo on remote server via ssh
for server in "${servers[@]}"; do
sshpass -p "password" ssh -T username@${server} 'echo password | sudo echo "11.16.18.10 hostname.domain.org" | sudo tee /etc/hosts'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment