A configurable OpenSSH server Docker container with GitHub public key integration and dual port support.
| Variable | Description | Required | Default |
|---|---|---|---|
SSH_USER | Username for SSH access | Yes | - |
SSH_PASSWORD | Password for SSH_USER (optional) | No | - |
GITHUB_USER | GitHub username to fetch public keys | No | - |
SSH_PASSWORD is provided: Password authentication enabled for SSH_USERSSH_PASSWORD is empty: Password authentication disabledGITHUB_USER is provided: Public keys fetched and added to both SSH_USER and rootdocker build -t openssh-server .
docker run -d \
--name ssh-server \
-p 2222:22 \
-p 2223:2222 \
-e SSH_USER=myuser \
-e SSH_PASSWORD=mypassword \
openssh-server
docker run -d \
--name ssh-server \
-p 2222:22 \
-p 2223:2222 \
-e SSH_USER=myuser \
-e GITHUB_USER=your-github-username \
openssh-server
docker run -d \
--name ssh-server \
-p 2222:22 \
-p 2223:2222 \
-e SSH_USER=myuser \
-e SSH_PASSWORD=mypassword \
-e GITHUB_USER=your-github-username \
openssh-server
# Using default port (22)
ssh myuser@localhost -p 2222
# Using custom port (2222)
ssh myuser@localhost -p 2223
# Only works if GITHUB_USER was provided and has public keys
ssh root@localhost -p 2222
.
├── Dockerfile # Main container definition
├── entrypoint.sh # Container startup script
├── custom.conf # SSH daemon configuration
└── README.md # This file
The container uses a modular SSH configuration approach:
/etc/ssh/sshd_config/etc/ssh/sshd_config.d/custom.confprohibit-password)Check if at least one authentication method is configured:
docker logs ssh-server
Common issues:
SSH_USER not providedSSH_PASSWORD empty and GITHUB_USER has no public keysVerify the container is running and ports are exposed:
docker ps
docker port ssh-server
Check if the GitHub user has public keys:
curl https://github.com/your-username.keys
docker run -d \
--name dev-ssh \
-p 2222:22 \
-e SSH_USER=developer \
-e SSH_PASSWORD=devpass \
-e GITHUB_USER=your-github-username \
openssh-server
docker run -d \
--name prod-ssh \
--restart unless-stopped \
-p 22:22 \
-p 2222:2222 \
-e SSH_USER=admin \
-e GITHUB_USER=your-github-username \
openssh-server
This project is provided as-is for educational and development purposes.
Content type
Image
Digest
sha256:579c60e97…
Size
43.9 MB
Last updated
about 1 year ago
docker pull s4l3h1/ssh