skip to Main Content

I tried to execute Docker-compose build but getting the below error.

I’m using centos7 and completely new to 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

Answers


  1. add this line

    RUN yum install -y passwd

    Login or Signup to reply.
  2. add this line its working:

    RUN yum install -y passwd
    

    And comment this line:

    RUN /usr/sbin/sshd-keygen
    
    Login or Signup to reply.
  3. You need to install passwd because the remote host does not have passwd installed. Add below line before the passwd command.

    RUN yum install -y passwd 
    
    Login or Signup to reply.
  4. That should work

    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
    
    Login or Signup to reply.
  5. This should work,

    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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search