/ bin / sh:passwd:找不到命令

时间:2020-03-28 12:11:51

标签: linux docker jenkins docker-compose

我尝试执行Docker-compose构建,但出现以下错误。

我正在使用centos7,这对Linux来说是全新的。

/bin/sh: passwd: command not found.
ERROR: Service 'remote_host' failed to build: The command '/bin/sh -c useradd remote_user &&     echo "welcome1" | passwd remote_user --stdin &&     mkdir /home/remote_user/.ssh &&     chmod 700 /home/remote_user/.ssh' returned a non-zero code: 127.

DockerFile。

FROM centos: latest
RUN yum -y install OpenSSH-server

RUN useradd remote_user && \
    echo "welcome1" | passwd remote_user --stdin && \
    mkdir /home/remote_user/.ssh && \
    chmod 700 /home/remote_user/.ssh`enter code here`

COPY remote-key.pub /home/remote_user/.ssh/authorized_keys

RUN chown remote_user:remote_user -R /home/remote_user chmod 600 /home/remote_user/.ssh/authorized_keys

RUN /usr/sbin/sshd-keygen

CMD /usr/sbin/sshd -D

whoami:mosses987 $ PATH:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/mosses987/.local/bin:/home/mosses987/bin

5 个答案:

答案 0 :(得分:3)

这应该可行,

#1

答案 1 :(得分:2)

在此行添加其工作内容:

RUN yum install -y passwd

并对这一行发表评论:

RUN /usr/sbin/sshd-keygen

答案 2 :(得分:0)

添加此行

运行yum install -y passwd

答案 3 :(得分:0)

您需要安装passwd,因为远程主机没有passwd installed。在passwd命令之前添加以下行。

RUN yum install -y passwd 

答案 4 :(得分:0)

应该可以

FROM centos:7


RUN yum update -y && \
    yum -y install openssh-server && \
    yum install -y passwd


RUN useradd remote_user  && \
    echo "1234" | passwd remote_user --stdin && \
    mkdir /home/remote_user/.ssh && \
    chmod 700 /home/remote_user/.ssh


COPY remote-key.pub /home/remote_user/.ssh/authorized_keys


RUN chown -R remote_user:remote_user /home/remote_user/.ssh && \
    chmod -R 600 /home/remote_user/.ssh/authorized_keys


RUN /usr/sbin/sshd-keygen


CMD /usr/sbin/sshd -D