当我在 alpine linux 上安装 sshpass 时,它会安装,并且如果您在没有参数的情况下运行它,但使用任何参数(有效或无效)会返回sshpass: Failed to run command: No such file or directory
.
它是有路径的,即使使用绝对路径,它也具有相同的行为。我想将它与 ansible 一起使用,但它甚至不能直接工作。
我似乎无法在网上找到有关此功能或对其他人不起作用的任何信息,但我使用了其他人的容器和我自己的容器,但我无法让它在任何一个上运行。 https://pkgs.alpinelinux.org/package/v3.3/main/x86/sshpass
$ docker run -it --rm williamyeh/ansible:alpine3 ash
/ # 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
/ # sshpass hi
sshpass: Failed to run command: No such file or directory
/ # which sshpass
/usr/bin/sshpass
/ # /usr/bin/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
/ # /usr/bin/sshpass anyinput
sshpass: Failed to run command: No such file or directory
值得一提的是,底层 ssh 可执行文件可以正常工作,我可以通过这种方式连接到主机。
SSHpass 工作正常,但 alpine 容器 python:3.6-alpine 没有安装 openssh。
此错误消息令人困惑,因为它没有提到 ssh 组件失败。
这可以通过运行来修复
apk add --update openssh
。这已通过将 Dockerfile 中的行从 更改为
RUN apk add --update --no-cache sshpass
来解决RUN apk add --update --no-cache openssh sshpass
。No such file or directory
指hi
和anyinput
:)我刚刚在 alpine 虚拟机上安装了 sshpass 并且
按预期工作。
PS:我相信你知道你在做什么和东西,但请确保你已经查看了公钥身份验证,然后再进行类似
sshpass
.