| 1 | # create the docker file |
| 2 | |
| 3 | cat > Dockerfile << 'EOF' |
| 4 | FROM ubuntu:latest |
| 5 | ENV DEBIAN_FRONTEND=noninteractive |
| 6 | # Install SSH server |
| 7 | RUN apt-get update && apt-get install -y openssh-server |
| 8 | # Configure SSH |
| 9 | RUN mkdir /var/run/sshd |
| 10 | RUN echo 'root:my_password' | chpasswd |
| 11 | # Allow root login |
| 12 | RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config |
| 13 | # SSH login fix |
| 14 | RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd |
| 15 | EXPOSE 22 |
| 16 | CMD ["/usr/sbin/sshd", "-D"] |
| 17 | EOF |
| 18 | |
| 19 | docker build -t continue-ubuntu-ssh . # build the image |
| 20 | |
| 21 | rm Dockerfile # remove the created Dockerfile |
| 22 | |
| 23 | container_name="continue-ssh-container" |
| 24 | |
| 25 | docker run -d -p 2222:22 --name $container_name continue-ubuntu-ssh # run the container |
| 26 | |
| 27 | echo "docker container ${container_name} running on port 2222" |
| 28 | |
| 29 | # add the instructions |
| 30 | bold=$(tput bold) |
| 31 | normal=$(tput sgr0) |
| 32 | |
| 33 | echo "\n--------------------------------------" |
| 34 | echo "now ssh into vscode (using remote explorer) with the following command: ${bold}ssh root@localhost -p 2222${normal}" |
| 35 | echo "use the following password - \"${bold}my_password${normal}\"" |