I am trying to create a ubuntu container using podman and able to bring up the container successfully. However when I try to ssh into the container using ssh-keys it is not working. Here is my Dockerfile looks like
FROM ubuntu:latest
RUN apt update && apt install openssh-server sudo -y
# Create a user “sshuser” and group “sshgroup”
RUN groupadd sshgroup && useradd -ms /bin/bash -g sshgroup sshuser
# Create sshuser directory in home
RUN mkdir -p /home/sshuser/.ssh
# Copy the ssh public key in the authorized_keys file. The idkey.pub below is a public key file you get from ssh-keygen. They are under ~/.ssh directory by default.
COPY id_rsa.pub /home/sshuser/.ssh/authorized_keys
# change ownership of the key file.
RUN chown sshuser:sshgroup /home/sshuser/.ssh/authorized_keys && chmod 600 /home/sshuser/.ssh/authorized_keys
# Start SSH service
RUN service ssh start
# Expose docker port 22
EXPOSE 22
CMD ["/usr/sbin/sshd","-D"]
When I tried ssh into the container using private key I am not getting any error and ssh is not successful
# ssh -i id_rsa [email protected]
Connection to 10.88.0.17 closed by remote host.
Connection to 10.88.0.17 closed.
Could some one let me know what could be the issue