sshpassはAlpine Linuxでは動作しません

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実行可能ファイルが機能し、この方法でホストに接続できることに言及する価値があります。

ベストアンサー1

SSHpassはうまく機能しますが、アルパインコンテナpython:3.6-alpineにはopensshがインストールされていません。

このエラー メッセージは、SSH コンポーネントが失敗したことに言及していないため、混乱しています。

この問題はを実行することで解決できますapk add --update openssh

RUN apk add --update --no-cache sshpassDockerfileの行をからに変更することで問題を解決しましたRUN apk add --update --no-cache openssh sshpass

おすすめ記事