linux /bin/sh:passwd:未找到命令

klh5stk1  于 2023-08-03  发布在  Linux
关注(0)|答案(6)|浏览(267)

我尝试执行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

zsohkypk

zsohkypk1#

添加这一行
运行yum install -y passwd

niwlg2el

niwlg2el2#

应该可以

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

字符串

jobtbby3

jobtbby33#

在同一个文件中,我遇到了同样的问题,但通过帖子written by Jaimil Patel解决了它,但出现了一个新的错误,关于ssh_host_rsa_key未找到,所以我通过添加下面的块解决了这个错误

RUN  ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key && \
     ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key && \
     ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key && \
     ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ed25519_key

字符串
尝试使用ssh登录到远程容器时出现新错误
第一个月
所以我通过添加
rm /run/nologin

dockerfile更新版本

FROM centos

RUN cd /etc/yum.repos.d/ && \
 sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \
 sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

RUN yum -y install openssh-server passwd

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

RUN  ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key && \
     ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key && \
     ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key && \
     ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ed25519_key

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 && \
    rm /run/nologin


CMD /usr/sbin/sshd -D

sqserrrh

sqserrrh4#

添加这一行其工作:

RUN yum install -y passwd

字符串
并注解这一行:

RUN /usr/sbin/sshd-keygen

wfveoks0

wfveoks05#

这应该能行

FROM centos

RUN yum -y install openssh-server

RUN 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 remote_user:remote_user -R /home/remote_user/.ssh/ && \
    chmod 600 /home/remote_user/.ssh/authorized_keys

#RUN /usr/sbin/sshd-keygen

CMD /usr/sbin/sshd -D

字符串

bd1hkmkf

bd1hkmkf6#

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

RUN yum install -y passwd

字符串

相关问题