SSH password entering automation in Jenkins with sshpass

sshpass is a simple and lightweight command line tool that enables us to provide password (non-interactive password authentication) to the command prompt itself, so that automated shell scripts can be executed.

Example1 - copying a file with scp:

sshpass -p $HOSTPWD scp -o StrictHostKeyChecking=no ./artifacts.zip jenkins@$HOST:~

Example2 - executing some commands:
sshpass -p $HOSTPWD ssh -o StrictHostKeyChecking=no -t -t jenkins@$HOST "(
        sudo -u tomcat /opt/tomcat/bin/shutdown.sh
        cd ~
        rm -rf artifacts.zip
    )"

Variables defined as secrets in Jenkins and sshpass options:
HOST - target SSH host
HOSTPWD - SSH password for user jenkins
-t -t - force pseudo-tty allocation even if stdin isn't a terminal (needed by sudo)