Last active
September 3, 2018 11:53
-
-
Save halleshubham/4d69cd47a99a11c28fe8c618f4c28436 to your computer and use it in GitHub Desktop.
BASH: Deploy and execute script on remote Linux node
This file contains 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 | |
PASSWORD=<PASSWORD> | |
node=<IP> | |
# Copy to remote node | |
echo y | pscp -pw "${PASSWORD}" /path/to/Script.sh <user>@"$node":/tmp/Script.sh | |
# Move to required / accessible directory | |
echo y | plink -ssh -pw "${PASSWORD}" -t <user>@"$node" "sudo cp /tmp/Script.sh /required/path/" | |
# Convert to Linux BASH (if file edited in Windows) | |
plink -ssh -pw "${PASSWORD}" -t <user>@"$node" "sed -i 's/\r$//' /required/path/Script.sh" | |
# Sudo execute | |
echo y | plink -ssh -pw "${PASSWORD}" -t <user>@"$node" "sudo bash /required/path/Script.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment