Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
cb5562272c | |||
12c970cd9f | |||
a0c265c6ca | |||
239adbeb9c | |||
1618a74f8d | |||
4cfda0ca4b | |||
2c3e6aca0c | |||
ec7c99328c |
4 changed files with 40 additions and 2 deletions
|
@ -2,7 +2,8 @@ FROM alpine:3.22
|
|||
|
||||
RUN apk update && apk upgrade && apk add --no-cache \
|
||||
git \
|
||||
docker \
|
||||
docker-cli \
|
||||
docker-cli-compose \
|
||||
bash \
|
||||
fish \
|
||||
zsh \
|
||||
|
@ -29,9 +30,15 @@ COPY service.ssh.sh /app/
|
|||
COPY service.ttyd.sh /app/
|
||||
RUN chmod +x /app/entrypoint.sh /app/service.ssh.sh /app/service.ttyd.sh
|
||||
|
||||
COPY motd.txt /etc/motd
|
||||
|
||||
RUN mkdir -p /srv/stack
|
||||
WORKDIR /srv/stack
|
||||
|
||||
# Set environment variable for Docker Compose project name
|
||||
# This is needed because inside ttyd docker compose defaults to hostname + directory for the project name
|
||||
ENV COMPOSE_PROJECT_NAME=stack
|
||||
|
||||
EXPOSE 22 1234
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
|
|
@ -22,6 +22,22 @@ if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
|
|||
ssh-keygen -A
|
||||
fi
|
||||
|
||||
if [ -f /etc/ssh/sshd_config -a `cat /etc/ssh/sshd_config | wc -l` = 1 ]; then
|
||||
echo "sshd_config is not complete, regenerating..."
|
||||
rm -f /etc/ssh/sshd_config
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/ssh/sshd_config ]; then
|
||||
echo "Include /etc/ssh/sshd_config.d/*.conf" > /etc/ssh/sshd_config
|
||||
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
|
||||
echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config
|
||||
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
|
||||
echo "AllowTcpForwarding no" >> /etc/ssh/sshd_config
|
||||
echo "GatewayPorts no" >> /etc/ssh/sshd_config
|
||||
echo "X11Forwarding no" >> /etc/ssh/sshd_config
|
||||
echo "Subsystem sftp internal-sftp" >> /etc/ssh/sshd_config
|
||||
fi
|
||||
|
||||
# Array to store child PIDs
|
||||
declare -a CHILD_PIDS=()
|
||||
|
||||
|
|
0
motd.txt
Normal file
0
motd.txt
Normal file
|
@ -1,3 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
exec /usr/sbin/sshd -D
|
||||
if [ ! -e /etc/ssh/sshd_config ]; then
|
||||
mkdir -p /etc/ssh/sshd_config.d
|
||||
echo "Include /etc/ssh/sshd_config.d/*.conf
|
||||
PermitRootLogin yes
|
||||
AuthorizedKeysFile .ssh/authorized_keys
|
||||
PasswordAuthentication yes
|
||||
AllowTcpForwarding yes
|
||||
GatewayPorts no
|
||||
X11Forwarding no
|
||||
Subsystem sftp internal-sftp" > /etc/ssh/sshd_config
|
||||
fi
|
||||
|
||||
# Cloud image generates this file which prevents sshd from accepting passwords
|
||||
rm -f /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
|
||||
exec /usr/sbin/sshd -E /var/log/sshd.log -D
|
||||
|
|
Loading…
Reference in a new issue