SSHPass is a utility for non-interactively performing password authentication with SSH. While it's convenient, be aware of security risks such as the potential leak of passwords.
Install SSHPass:
To install SSHPass, use the following command:
dnf -y install sshpass
Pass Password via Argument:
Use the -p option to pass the password directly as an argument (not recommended for security reasons).
sshpass -p password ssh remote_host
Example:
sshpass -p password ssh node01.emc.world hostname
Create a Password File:
Store your password in a file and secure it with appropriate permissions.
echo 'password' > sshpass.txt
chmod 600 sshpass.txt
Pass Password via File:
Use the -f option to read the password from a file.
sshpass -f sshpass.txt ssh remote_host
Example:
sshpass -f sshpass.txt ssh node01.emc.world hostname
Set Password in Environment Variable:
Export your password as an environment variable SSHPASS.
export SSHPASS=password
Use Environment Variable for Password:
Use the -e option to read the password from the SSHPASS environment variable.
sshpass -e ssh remote_host
Example:
sshpass -e ssh node01.emc.world hostname
Note: Replace remote_host, node01.emc.world, password, and other placeholders with actual server addresses, hostnames, and passwords relevant to your setup. Be cautious with password management to mitigate security risks.