-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsh_insert_content.text
More file actions
46 lines (44 loc) · 2.23 KB
/
Copy pathsh_insert_content.text
File metadata and controls
46 lines (44 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
- trigger: post-files
action: |-
#!/bin/sh
set -eux
cd /etc/ssh || true
ssh-keygen -A || true
sed -i "s/^#\?\(Port\).*/\1 22/" /etc/ssh/sshd_config || true
sed -i -E 's/^#?(Port).*/\1 22/' /etc/ssh/sshd_config || true
sed -i 's/^#\?Port.*/Port 22/g' /etc/ssh/sshd_config || true
sed -i '/^#PermitRootLogin\|PermitRootLogin/c PermitRootLogin yes' /etc/ssh/sshd_config || true
sed -i "s/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config || true
sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config || true
sed -i 's/#ListenAddress ::/ListenAddress ::/' /etc/ssh/sshd_config || true
sed -i '/^#AddressFamily\|AddressFamily/c AddressFamily any' /etc/ssh/sshd_config || true
sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config || true
sed -E -i 's/preserve_hostname:[[:space:]]*false/preserve_hostname: true/g' /etc/cloud/cloud.cfg || true
sed -E -i 's/disable_root:[[:space:]]*true/disable_root: false/g' /etc/cloud/cloud.cfg || true
sed -E -i 's/ssh_pwauth:[[:space:]]*false/ssh_pwauth: true/g' /etc/cloud/cloud.cfg || true
# other config
/usr/sbin/sshd || true
rc-update add sshd default || true
/etc/init.d/cron enable || true
/etc/init.d/cron start || true
grep -q '^PermitRootLogin yes' /etc/ssh/sshd_config || echo "PermitRootLogin yes" >> /etc/ssh/sshd_config || truez
mkdir -p /etc/modprobe.d/ || true
echo "install algif_aead /bin/false" > /etc/modprobe.d/disable-algif.conf || true
echo -e "Related repo https://github.com/oneclickvirt/lxd_images\n--by https://t.me/spiritlhl" >> /etc/motd || true
echo -e "Related repo https://github.com/oneclickvirt/lxd_images\n--by https://t.me/spiritlhl" >> /etc/banner || true
# clean package manager caches to reduce image size
if command -v apk >/dev/null 2>&1; then
rm -rf /var/cache/apk/* || true
fi
if command -v opkg >/dev/null 2>&1; then
rm -rf /var/cache/opkg/* /tmp/opkg-* || true
fi
# clean temporary files and logs
rm -rf /tmp/* /var/tmp/* || true
find /var/log -type f \( -name "*.log" -o -name "*.gz" \) -delete 2>/dev/null || true
types:
- container
- vm
variants:
- cloud
- default