sshpass 在 alpine linux 中不起作用

Bri*_*ian 4 ansible docker alpine-linux sshpass

当我在 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
Run Code Online (Sandbox Code Playgroud)

值得一提的是,底层 ssh 可执行文件可以工作,我可以通过这种方式连接到主机。

Bri*_*ian 12

SSHpass 工作正常,但 alpine 容器 python:3.6-alpine 没有安装 openssh。

此错误消息令人困惑,因为它没有提到 ssh 组件失败。

这可以通过运行来解决apk add --update openssh

这是通过更改在Dockerfile行解析RUN apk add --update --no-cache sshpassRUN apk add --update --no-cache openssh sshpass