Rocky_Linux_8
Sponsored Link

OpenSSH : Use SSHPass2021/07/19

 
Use SSHPass to automate inputting password on password authentication.
This is convenient but it has security risks (leak of password), take special care if you use it.
[1] Install SSHPass.
# install from EPEL

[root@dlp ~]#
dnf --enablerepo=epel -y install sshpass
[2] How to use SSHPass.
# [-p password] : from argument

[rocky@dlp ~]$
sshpass -p password ssh node01.srv.world hostname

node01.srv.world
# [-f file] : from file

[rocky@dlp ~]$
echo 'password' > sshpass.txt

[rocky@dlp ~]$
chmod 600 sshpass.txt

[rocky@dlp ~]$
sshpass -f sshpass.txt ssh node01.srv.world hostname

node01.srv.world
# [-e] : from environment variable

[rocky@dlp ~]$
export SSHPASS=password

[rocky@dlp ~]$
sshpass -e ssh node01.srv.world hostname

node01.srv.world
Matched Content