当我在 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 可执行文件可以工作,我可以通过这种方式连接到主机。
答案1
SSHpass 工作正常,但 alpine 容器 python:3.6-alpine 没有安装 openssh。
此错误消息令人困惑,因为它没有提到 ssh 组件发生故障。
这可以通过运行来修复apk add --update openssh
。
RUN apk add --update --no-cache sshpass
通过将Dockerfile 中的行从 更改为 解决了这个问题RUN apk add --update --no-cache openssh sshpass
。
答案2
No such file or directory
指的是hi
和anyinput
:)
我刚刚在 alpine 虚拟机上安装了 sshpass
# sshpass -p <my password> ssh 127.0.0.1
按预期工作。
聚苯乙烯:我确信你知道自己在做什么,但是请确保您在进行诸如 之类的事情之前已经研究过公钥身份验证sshpass
。