Interaction-free SSH login tool.
Interaction-free SSH login tool, but don't use it on production servers.
What if you want to automatically provide the password and username in the SSH login prompt? At this time sshpass can help you.
sshpass is a simple, lightweight command line tool through which we can provide a password to the command prompt itself (non-interactive password authentication).
#RedHat/CentOS
yum install sshpass
#Debian/Ubuntu
apt-get install sshpass
sshpass (option)
Usage: sshpass [-f|-d|-p|-e] [-hV] Command Parameters
-f filename Get password from file
-d number Use number as file descriptor to get password
-p password Provide password as argument (unwise security wise)
-e The password is passed as the environment variable "SSHPASS"
If no arguments - password will be taken from standard input
-P prompt string that sshpass searches to detect password prompts
-v show detailed information
-h displays help information (this screen)
-V print version information
Only one of -f, -d, -p or -e can be used
sshpass -p 'my_pass_here' ssh aaronkilik@10.42.0.1 'df -h'
sshpass -f password_filename ssh aaronkilik@10.42.0.1 'df -h'
sshpass -e ssh aaronkilik@10.42.0.1 'df -h'
For more usage details, please refer to https://linux.cn/article-8086-1.html.