FreeBSD 14
Sponsored Link

OpenSSH : Use SSHPass2023/12/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.
root@dlp:~ #
pkg install -y sshpass
[2] How to use SSHPass.
# [-p password] : from argument
# if initial connection, add [StrictHostKeyChecking=no]

freebsd@dlp:~ $
sshpass -p password ssh -o StrictHostKeyChecking=no 10.0.0.51 hostname

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

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

freebsd@dlp:~ $
chmod 600 sshpass.txt

freebsd@dlp:~ $
sshpass -f sshpass.txt ssh 10.0.0.51 hostname

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

freebsd@dlp:~ $
export SSHPASS=password

freebsd@dlp:~ $
sshpass -e ssh 10.0.0.51 hostname

node01.srv.world
Matched Content