源码方式安装sshpass

sshpass是一个可以实现免交互的SSH登录工具,在一些自动化运维场景非常有用。
在RHEL8或者CentOS8环境,虽然已经配置了yum源,但是依然无法直接通过yum或者dnf安装sshpass,报错如下:

[root@zhangsan ~]# yum install sshpass
Last metadata expiration check: 3:50:40 ago on Fri 06 Jan 2023 06:38:55 PM CST.
No match for argument: sshpass
Error: Unable to find a match: sshpass
[root@zhangsan ~]#

可以采用源码编译方式安装sshpass。

第一步:下载sshpass源码。
第二步:编译安装。

[root@zhangsan ~]# tar xvf sshpass-1.08.tar.gz
[root@zhangsan ~]# cd sshpass-1.08
[root@zhangsan ~]# ./configure
[root@zhangsan ~]# make
[root@zhangsan ~]# make install

sshpass命令用法:

[root@linuxprobe ~]# sshpass 
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
   -f filename   Take password to use from file
   -d number     Use number as file descriptor for getting password
   -p password   Provide password as argument (security unwise)
   -e            Password is passed as env-var "SSHPASS"
   With no parameters - password will be taken from stdin

   -P prompt     Which string should sshpass search for to detect a password prompt
   -v            Be verbose about what you're doing
   -h            Show help (this screen)
   -V            Print version information
At most one of -f, -d, -p or -e should be used
[root@linuxprobe ~]#

拷贝本地文件到远程主机示例:

[root@linuxprobe ~]# sshpass -p 123456 scp /home/file.txt root@10.0.0.37:/home/copy

【参考】
https://blog.csdn.net/lin_keys/article/details/115175695 安装不了sshpass解决办法


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达,在下面评论区告诉我^_^^_^