debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: filesystem full
debug1: channel 0: free: client-session, nchannels 1
Connection to ssh.frankfurt.render.com closed by remote host.
Connection to ssh.frankfurt.render.com closed.
Transferred: sent 2760, received 1464 bytes, in 15.7 seconds
Bytes per second: sent 175.8, received 93.2
debug1: Exit status -1
When I use root user in ssh command, then I have Permission denied (publickey).
Did anyone succeeded in ssh’ing into an alpine container?
With what user?
For Docker services, SSH needs to be able to set up permissions correctly. It’s trying to write to ~/.ssh, which for your user is /.ssh (note the 6th part of the passwd entry, where the user’s home directory is /). You can modify your Docker container to support this by changing:
USER nobody:nobody
to:
RUN mkdir /.ssh
RUN chown nobody:nobody /.ssh
USER nobody:nobody
Additionally, your container has configured the nobody user to not support logging in (and therefore SSH), which is what the last part of the passwd entry is communicating with /sbin/nologin. You can change this by adding sed -ri 's/^(nobody.*:)\/sbin\/nologin$/\1\/bin\/sh/' /etc/passwd in your Dockerfile before switching users. Putting it all together, you have:
RUN mkdir /.ssh
RUN chown nobody:nobody /.ssh
RUN sed -ri 's/^(nobody.*:)\/sbin\/nologin$/\1\/bin\/sh/' /etc/passwd
USER nobody:nobody
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: filesystem full
debug1: channel 0: free: client-session, nchannels 1
Connection to ssh.frankfurt.render.com closed by remote host.
Connection to ssh.frankfurt.render.com closed.
Transferred: sent 2760, received 1464 bytes, in 15.5 seconds
Bytes per second: sent 178.2, received 94.5
debug1: Exit status -1
I think a cause may have been the ENV HOME statement?
It happens ~nobody/.ssh is empty:
/app $ cd ~nobody/.ssh
/.ssh $ ls -laF
total 8
drwxr-sr-x 2 nobody nobody 4096 Feb 4 10:03 ./
drwxr-xr-x 1 root root 4096 Feb 4 10:21 ../