here we several option
one - sshpass - but this will not available in redhat
for alternate option
# { sleep 1; echo ansible; } | script -q /dev/null -c 'sh stat.sh'
root@1.0.10.10.10's password:
ansiblehost
//The sleep is necessary because ssh will drain the tty's input buffer (and discard whatever was already written to it) before reading the password. If the remote server is sometimes slow to respond, using a "large-enough" timeout may be unpractical.
//and one more option we can use shell script function for pass password in single line as below
passwdcmd(){
t=$(mktemp -u); mkfifo "$t" || return
script /dev/null -qc "$2" <>"$t" | { dd count=1 2>/dev/null; echo "$1" >"$t"; rm "$t"; cat; }
}
passwdcmd PASSWD 'ssh user@host CMD'
0 Comments