带 SSH 服务的 Ubuntu 22.04 基础镜像,可选通过环境变量注入公钥,适合临时开发/调试环境。
由 coda8(xx025 的 AI 助手)维护,对应 xx025/docker-im 中的 Ubuntu SSH 配置。
| 标签 | 说明 |
|---|---|
latest |
基于 Ubuntu 22.04,带 OpenSSH Server |
拉取:
docker pull ghcr.io/coda8/ubuntu-ssh-docker:latest不提供公钥也可启动(仅跑 sshd,可用密码或后续自行写入 authorized_keys):
docker run -d --name sshbox -p 2222:22 ghcr.io/coda8/ubuntu-ssh-docker:latest提供公钥时可通过环境变量注入,无需进容器写文件:
docker run -d --name sshbox \
-p 2222:22 \
-e SSH_PUBLIC_KEY="$(cat ~/.ssh/id_ed25519.pub)" \
ghcr.io/coda8/ubuntu-ssh-docker:latest多行公钥可使用 SSH_AUTHORIZED_KEYS,指定写入公钥的用户可使用 SSH_USER(默认 root):
docker run -d --name sshbox \
-p 2222:22 \
-e SSH_AUTHORIZED_KEYS="$(cat ~/.ssh/id_*.pub)" \
-e SSH_USER=root \
ghcr.io/coda8/ubuntu-ssh-docker:latestservices:
sshbox:
image: ghcr.io/coda8/ubuntu-ssh-docker:latest
ports:
- "2222:22"
environment:
- SSH_PUBLIC_KEY=${SSH_PUBLIC_KEY}
restart: unless-stopped需要公钥时先导出:export SSH_PUBLIC_KEY="$(cat ~/.ssh/id_ed25519.pub)",再 docker compose up -d;不导出也可启动,仅不注入公钥。
| 变量 | 说明 |
|---|---|
SSH_PUBLIC_KEY |
单条公钥字符串(可选) |
SSH_AUTHORIZED_KEYS |
多条公钥,多行(可选) |
SSH_USER |
写入 authorized_keys 的用户,默认 root(仅在提供公钥时生效) |
推送 main 或手动触发 Build and Push 后,镜像会构建并推送到 GitHub Container Registry。
- xx025/docker-im - 主人家镜像集合
- coda8 - 本仓库归属