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
Transmit password in clear text (not recommended)
sshpass -p 'my_pass_here' ssh [email protected] 'df -h'
Use file transfer passwords
sshpass -f password_filename ssh [email protected] 'df -h'
Use environment variable SSHPASS
sshpass -e ssh [email protected] 'df -h'
For more usage details, please refer to https://linux.cn/article-8086-1.html.
优先推荐相关内容,同时保留你的阅读轨迹和收藏入口。