文章目錄
- 信息
- 新建用戶
- 服務重啟
- 數據庫相關
- SSH
- 無交互安裝
- auth.log
- ssh開機自啟
- Apache服務配置
信息
Alpine
系統
新建用戶
useradd命令參考
RUN apk update \ && apk add shadow \&& useradd -m togie \&& echo 'togie:12345' | chpasswd \&& && echo 'togie ALL=(ALL:ALL) ALL' >> /etc/sudoers
# 這里加所有權限了
# -m:自動建立用戶的登入目錄
# -u: 創建用戶并自定義UID值 useradd -u 6688 user3
# # 增普通用戶-DebianRUN useradd -m janitor \&& usermod -s /bin/bash \
服務重啟
# alpine
# 如果提示沒有rc-service,則需要安裝openrc包
RUN apk update \&& apk add openrc \&& apk add openssh \&& echo "PermitRootLogin yes" >> /etc/ssh/sshd_config \&& rc-service sshd restart \# debianservice ssh restart/etc/init.d/sshd start
數據庫相關
COPY src/wordpress.sql /tmp/wordpress.sqlRUN apt-get install mariadb-server \&& mysql -uroot -proot -e "create user 'Admin'@'localhost' identified by 'TogieMYSQL12345^^';" \&& mysql -uroot -proot -e "create database wordpress character set utf8mb4 collate utf8mb4_unicode_ci;" \&& mysql -uroot -proot -e "use wordpress; source /tmp/wordpress.sql;" \&& mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'Admin'@'localhost';" \&& mysql -uroot -proot -e "FLUSH PRIVILEGES;" \# /etc/init.d/mariadb start 開機executable中啟動服務
SSH
在大多數情況下,Alpine Linux并不提供rc-service命令。rc-service是OpenRC init系統的命令,而Alpine Linux通常使用OpenRC作為其init系統。
如果你的Alpine Linux系統沒有rc-service命令,而你需要使用OpenRC命令,你可以嘗試安裝openrc軟件包,這樣就可以獲取rc-service命令。請注意,安裝軟件包可能需要管理員權限。
# 如果提示沒有rc-service,則需要安裝openrc包
RUN apk update \&& apk add openrc \&& apk add openssh \&& echo "PermitRootLogin yes" >> /etc/ssh/sshd_config \&& rc-service sshd restart \
# ubuntu
RUN apt-get update \&& DEBIAN_FROnTEND=noninteractive apt-get -yq install openssh-server \&& echo "PermitRootLogin yes" >> /etc/ssh/sshd_config \&& /etc/init.d/ssh restart \&& apt install rsyslog \&& service rsyslog restart \
無交互安裝
DEBIAN_FROnTEND=noninteractive apt-get -yq install參考https://www.php1.cn/detail/ubuntu_RuHeRang__b4654097.html
auth.log
# 如果需要生成auth.log,需要有用戶為rsyslogapt install rsyslog \service rsyslog restart \參考https://www.cnblogs.com/ALice1024/p/17259176.html
ssh開機自啟
https://blog.csdn.net/qq_45818845/article/details/123951906
startup_run.sh
#!/bin/bashLOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
echo "[$LOGTIME] startup run..." >>/root/startup_run.log
service ssh start >>/root/startup_run.log
#service mysql start >>/root/startup_run.log
Apache服務配置
RUN tar -zxvf /tmp/conf.tar.gz -C /tmp/apache2 \&& cp /tmp/apache2/sites-available/theEther.com.conf /etc/apache2/sites-available/000-default.conf \&& cp /tmp/apache2/sites-available/theEther.com.conf /etc/apache2/sites-enabled/000-default.conf \&& echo 'DOCUMENTROOT "/var/www/html/theEther.com/public_html"' >> /etc/apache2/apache2.conf \
# 解壓帶更換靶機中apache網站配置文件,源文件一般在/etc/apache2文件夾