Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions containers/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update; \
apt-get install -y --no-install-recommends \
locales git wget vim sudo nano jq make unzip \
openssh-server \
curl ca-certificates gnupg lsb-release \
libnss3 libxrandr2 libxss1 \
fonts-noto-cjk fonts-noto-cjk-extra; \
Expand Down Expand Up @@ -123,6 +124,12 @@ RUN groupadd -f users; \
echo "$USERNAME ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME; \
chmod 0440 /etc/sudoers.d/users /etc/sudoers.d/$USERNAME

# sshd 設定(Orca 向け: 公開鍵認証のみ・Password 無効・TcpForwarding 有効)
RUN set -eux; \
mkdir -p /run/sshd /etc/ssh/sshd_config.d; \
printf 'PasswordAuthentication no\nPubkeyAuthentication yes\nAllowTcpForwarding yes\nX11Forwarding no\nPermitRootLogin no\n' \
> /etc/ssh/sshd_config.d/10-devbase-orca.conf

USER ${USERNAME}
WORKDIR /tmp

Expand Down
36 changes: 36 additions & 0 deletions containers/base/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,42 @@ done
echo "AI agent settings symlinks setup completed"
# ========================================

# ========================================
# SSH server (Orca 連携) — enabled by ENABLE_SSH=true
# ========================================
# NOTE: ~/.ssh は上の symlink setup で /persistent/ai/.ssh に張り替え済みのため、
# authorized_keys の書き込みはこのブロック(symlink 生成後)で行う必要がある。
if [ "$ENABLE_SSH" = "true" ] || [ "$ENABLE_SSH" = "1" ]; then
echo "Starting sshd for Orca..."

# host key を永続領域から復元、無ければ生成して保存する。
# 再ビルド/再作成で host key が変わると Orca 側 known_hosts が壊れるのを防ぐ。
# HOST_KEY_DIR は .ssh symlink とは別の独立ディレクトリ(ドット無し)。
HOST_KEY_DIR="/persistent/ai/ssh"
sudo mkdir -p "$HOST_KEY_DIR" || true
if ! sudo ls "$HOST_KEY_DIR"/ssh_host_*_key >/dev/null 2>&1; then
echo "Generating new sshd host keys..."
sudo ssh-keygen -A
sudo cp /etc/ssh/ssh_host_*_key* "$HOST_KEY_DIR"/ 2>/dev/null || true
fi
# 永続領域から /etc/ssh へ復元(毎回)
sudo cp "$HOST_KEY_DIR"/ssh_host_*_key* /etc/ssh/ 2>/dev/null || true

# authorized_keys の展開(.ssh は /persistent/ai/.ssh へ symlink 済み)
if [ -n "$SSH_AUTHORIZED_KEYS" ]; then
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "$SSH_AUTHORIZED_KEYS" > ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
echo "authorized_keys installed"
else
echo "Warning: SSH_AUTHORIZED_KEYS is empty; public-key login will not work"
fi

# sshd 起動(daemonize するため exec "$@" をブロックしない)
sudo /usr/sbin/sshd -e
echo "sshd started"
fi

# Git operations (optional, don't fail if they error)
if [ -n "$GIT_USER" ] && [ -n "$GIT_REPO" ]; then
# Clone repository only if it doesn't exist
Expand Down
9 changes: 9 additions & 0 deletions docs/user/container-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ graph TD
| **go** | base | Go 開発環境 | Go 開発 |
| **snapshot** | Ubuntu Noble | zstd のみ(約 80MB) | スナップショット専用 |

### SSH サーバー(Orca 連携)

base イメージには `openssh-server` が含まれます。環境変数 `ENABLE_SSH=true`(または `1`)を指定してコンテナを起動すると、entrypoint が sshd を起動します(既定は無効)。

- 認証は公開鍵のみ(`SSH_AUTHORIZED_KEYS` に手元の公開鍵を設定)。
- host key は `/persistent/ai/ssh/` に永続化され、再ビルド/再作成後も維持されます(Orca の known_hosts が壊れない)。

> **Note:** `openssh-server` の追加は base イメージの変更のため、既存イメージには `devbase build --no-cache`(base 再ビルド)が必要です。

### AI CLI エイリアス

general イメージ以降のコンテナ内では、以下の AI CLI ツールがエイリアスとして利用可能です。
Expand Down