Contoh Docker SSH Pada Ubuntu
Buat File Dockerfile
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:fahri' | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Buat Lagi docker-compose.yml
version: "3.9"
services:
ssh:
build: .
ports:
- "2200:22"
redis:
image: "redis:alpine"
Login Dengan
ssh root@localhost -p2200
Masukan Username : root
Password : Fahri
Lanjut Part : 1
Muhammad Ullil Fahri
WA : 089696380422
Tautan WA : https://wa.me/message/SG4YA2XQP5FPE1