Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BASH: Deploy and execute script on remote Linux node
#!/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