Ubuntu 18.04
Sponsored Link

OpenSSH : Use SSHPass2018/04/28

 
Use SSHPass to automate inputting password on password authentication.
This is convenient but has security risks (leak of password), take special care if you use it.
[1] Install SSHPass.
root@dlp:~#
apt -y install sshpass
[2] How to use SSHPass.
# -p password : from argument

# if initial connection, add [StrictHostKeyChecking=no]

ubuntu@dlp:~$
sshpass -p password ssh -o StrictHostKeyChecking=no 10.0.0.31 hostname

www.srv.world
# -f file : from file

ubuntu@dlp:~$
echo 'password' > sshpass.txt

ubuntu@dlp:~$
chmod 600 sshpass.txt

ubuntu@dlp:~$
sshpass -f sshpass.txt ssh 10.0.0.31 hostname

www.srv.world
# -e : from env variable

ubuntu@dlp:~$
export SSHPASS=password

ubuntu@dlp:~$
sshpass -e ssh 10.0.0.31 hostname

www.srv.world
Matched Content