Docker
sshpass 在 alpine linux 中不起作用
當我在 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 並且
# sshpass -p <my password> ssh 127.0.0.1
按預期工作。
PS:我相信你知道你在做什麼和東西,但請確保你已經研究過公鑰身份驗證,然後再進行類似
sshpass
.