Created
November 5, 2020 18:40
-
-
Save rafamdr/f7dd76987838971d1c62ecad4ae3c7d4 to your computer and use it in GitHub Desktop.
Bash script to execute a command through SSH passing username/password as parameters
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 | |
#!/usr/bin/expect | |
if [ ! "$BASH_VERSION" ] ; then | |
exec /bin/bash "$0" "$@" | |
fi | |
echo -n "SSH User": | |
read -r sshusertemp | |
echo -n "SSH Password": | |
read -sr sshpasswordtemp | |
printf "\n" | |
sshpass -p "$sshpasswordtemp" ssh -o StrictHostKeyChecking=no "$sshusertemp"@192.128.0.2 "ls -la" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment