FROM ubuntu:22.04

LABEL maintainer="Offends <offends4@163.com>"

RUN apt update \
    && apt install openssh-server vim -y

COPY ./file/.* /.file/
COPY ./start.sh /start.sh

RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/g' /etc/ssh/sshd_config \
    && sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config \
    && chmod +x /start.sh \
    && mkdir -p /etc/.pass/ \
    && openssl rand -base64 8 > /etc/.pass/.root_password \
    && chmod 005 /etc/.pass/.root_password \
    && echo "root:$(cat /etc/.pass/.root_password)" | chpasswd \
    && echo "Ubuntu 启动启动成功" > /var/log/start.log

EXPOSE 22

ENV ES_DEFAULT_EXEC_ARGS=bash

CMD [ "bash", "/start.sh" ]