diff --git a/TestDocker/SSH/Dockerfile b/TestDocker/SSH/Dockerfile new file mode 100644 index 0000000..9952185 --- /dev/null +++ b/TestDocker/SSH/Dockerfile @@ -0,0 +1,20 @@ +# 使用Ubuntu最新版本作为基础镜像 +FROM ubuntu:latest + +# 安装必要的软件包 +RUN apt-get update && apt-get install -y \ + openssh-server \ + && rm -rf /var/lib/apt/lists/* + +# 创建SSH所需的目录 +RUN mkdir /var/run/sshd + +# 允许root用户SSH登录并设置密码 +RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config +RUN echo 'root:123456' | chpasswd + +# 开放22端口 +EXPOSE 22 + +# 启动SSH服务 +CMD ["/usr/sbin/sshd", "-D"] \ No newline at end of file diff --git a/TestDocker/SSH/README.txt b/TestDocker/SSH/README.txt new file mode 100644 index 0000000..1d17fa9 --- /dev/null +++ b/TestDocker/SSH/README.txt @@ -0,0 +1,2 @@ +docker build -t ubuntu-ssh . +docker run -d -p 22:22 ubuntu-ssh \ No newline at end of file