【问题标题】:Unable to run sshpass command in centOS [closed]无法在centOS中运行sshpass命令[关闭]
【发布时间】:2019-07-31 16:34:00
【问题描述】:

在 CentOS release 6.3 (Final) 系统上工作。并尝试使用sshpass 等实用程序 ssh 另一台机器

sshpass -p 'password' ssh user@host

但它给了我类似的错误

sshpass: Failed to run command: No such file or directory

所以从错误中我认为sshpass 可能没有安装,所以尝试通过yum install sshpass 安装它并获取以下日志

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.leapswitch.com
 * epel: epel.mirror.net.in
 * extras: mirror.leapswitch.com
 * nux-libreoffice.org-rpms: mirror.li.nux.ro
 * updates: mirror.leapswitch.com
Setting up Install Process
Package sshpass-1.05-1.el6.i686 already installed and latest version
Nothing to do

从上面看来 sshpass 已经安装了。为什么它不起作用?

【问题讨论】:

    标签: ssh centos sshpass


    【解决方案1】:

    检查你的 shell 是否知道 sshpass 的位置

    which sshpass
    

    如果它没有给出任何输出,请使用 find 命令查找可执行文件的位置:

    find / -name sshpass
    

    如果找到路径,您可以使用可执行文件的完整路径:

    /path/to/sshnpass
    

    或者添加PATH环境变量的路径,让你的shell可以定位到:

    export PATH=$PATH:/path/to/
    

    或者问题可能完全不同。 sshpass 可能无法找到其他一些依赖项。可能未安装“ssh”客户端。或者你的语法可能是wrong:

    【讨论】:

    • 谢谢,使用which sshpass 我得到了路径/usr/bin/sshpass。所以它可以工作,但上面的路径需要导出意味着它的默认路径。
    • 您可能没有安装 ssh 客户端 "which ssh" 的输出是什么?如果它为空,则需要安装 ssh 客户端。
    • 输出是 /usr/bin/ssh。表示已经安装
    • 您输入的命令与您上面提到的完全一样吗?您可以尝试以下替代方法: sshpass -p 'password' /usr/bin/ssh user@host sshpass -p 'password' ssh user@localhost 您是在密码周围使用单引号还是双引号?如果你的密码有特殊字符,它可能会迫使 shell 错误的参数。
    • 测试用普通密码即可
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-22
    • 2014-01-26
    • 2021-11-24
    • 2020-02-05
    • 1970-01-01
    相关资源
    最近更新 更多