概要
デフォルトだと無効になっています
環境
- macOS 15.7.1
- docker 29.1.2
- linuxserver/openssh-server 10.0_p1-r10-ls211
compose.yaml
services:
ssh_server:
image: ghcr.io/linuxserver/openssh-server
container_name: ssh_server
ports:
- "2222:2222"
- "10022:10022" # SSHリモートポートフォーワードトンネル用
environment:
- PUID=1000
- PGID=1000
- PASSWORD_ACCESS=true
- USER_NAME=test
- USER_PASSWORD=mypass
volumes:
- ./custom-cont-init.d:/custom-cont-init.d:ro
restart: unless-stopped
custom-cont-init.d/01-sshd-config.sh
#!/bin/bash
# chmod +x config/custom-cont-init.d/01-sshd-config.sh を必ず実行
echo "[custom-init] modifying sshd_config..."
# AllowAgentForwarding
sed -i 's/#AllowAgentForwarding yes/AllowAgentForwarding yes/g' /config/sshd/sshd_config
# AllowTcpForwarding
sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /config/sshd/sshd_config
# GatewayPorts
sed -i 's/GatewayPorts no/GatewayPorts yes/g' /config/sshd/sshd_config
# X11Forwarding
sed -i 's/X11Forwarding no/X11Forwarding yes/g' /config/sshd/sshd_config
echo "[custom-init] done."
- chmod +x config/custom-cont-init.d/01-sshd-config.sh
動作確認
- docker compose up -d
- docker compose exec ssh_server cat /config/sshd/sshd_config
GatewayPorts などが yes になっていることを確認します
最後に
カスタムスクリプトを配置するパスが /custom-cont-init.d でした
バージョンによって異なるのでご注意ください
0 件のコメント:
コメントを投稿