A secure, feature-rich Docker container based on polinux/ubuntu22-supervisor that provides SSH access with configurable passwords, user creation, sudo privileges, and comprehensive logging.
π Quick Start β’ π Configuration β’ π€ Contributing β’ π Issues
π¦ docker-ssh-ubuntu22
βββ π³ Dockerfile # Main container definition
βββ π docker-compose.yml # Docker Compose configuration
βββ π README.md # This documentation
βββ π LICENSE # MIT License file
βββ π .github/ # GitHub configuration
β βββ π workflows/
β βββ π docker.yml # CI/CD pipeline for Docker Hub
βββ π container-files/ # Files copied to container
βββ βοΈ config/
β βββ π§ init/
β βββ π 10-init-set-root-pass.sh # Root password initialization script
β βββ π€ 20-init-create-user.sh # User creation and sudo setup script
βββ π etc/
βββ π₯ supervisor.d/
βββ π sshd.conf # SSH daemon supervisor config
| Feature | Description |
|---|---|
| π SSH Server | OpenSSH server pre-configured for secure root access |
| π€ User Creation | Automatically create users with custom passwords via environment variables |
| π Sudo Support | Grant sudo privileges to created users with passwordless access |
| π₯ Supervisor Management | Robust process management using supervisor |
| π Password Logging | All passwords logged to both stdout and persistent files |
| βοΈ Configurable Passwords | Set custom passwords or auto-generate secure ones |
| πΎ Persistent Logs | All logs stored in /data/logs/ for easy access |
| π Auto-restart | Services automatically restart on failure |
| π³ Docker Hub Ready | Available as pre-built image on Docker Hub |
# Pull the latest image
docker pull polinux/ssh-ubuntu22# Clone and build
git clone https://github.com/pozgo/docker-ssh-ubuntu22.git
cd docker-ssh-ubuntu22
docker build -t polinux/ssh-ubuntu22 .docker run -d -p 2222:22 --name ssh-container polinux/ssh-ubuntu22
# Default password: supersecurepassdocker run -d -p 2222:22 --name ssh-container \
-e ROOT_PASWD=mypassword \
polinux/ssh-ubuntu22docker run -d -p 2222:22 --name ssh-container \
-e ROOT_PASWD=password \
polinux/ssh-ubuntu22docker run -d -p 2222:22 --name ssh-container \
-e USER=developer \
polinux/ssh-ubuntu22docker run -d -p 2222:22 --name ssh-container \
-e USER=developer \
-e USER_IN_SUDO=true \
polinux/ssh-ubuntu22docker run -d -p 2222:22 --name ssh-container \
-e USER=developer \
-e USER_PASWD=my-secure-password \
polinux/ssh-ubuntu22docker run -d -p 2222:22 --name ssh-container \
-e USER=developer \
-e USER_PASWD=my-secure-password \
-e USER_IN_SUDO=true \
polinux/ssh-ubuntu22docker run -d -p 2222:22 --name ssh-container \
-e USER=developer \
-e USER_PASWD=password \
-e USER_IN_SUDO=true \
polinux/ssh-ubuntu22# Run the default service
docker compose up -d
# Run with custom password profile
docker compose --profile custom up -d ssh-custom
# Run with auto-generated password profile
docker compose --profile auto up -d ssh-auto
# Run with user creation profile
docker compose --profile user up -d ssh-user
# Run with user + sudo privileges profile
docker compose --profile sudo up -d ssh-sudo
# Run with user creation and custom password
docker compose --profile user-custom up -d ssh-user-custom
# Run with user + custom password + sudo privileges
docker compose --profile user-sudo-custom up -d ssh-user-sudo-custom
# Run with user + auto-generated password
docker compose --profile user-auto up -d ssh-user-auto
# Run development environment (user with sudo + auto password)
docker compose --profile dev up -d ssh-dev# Connect via SSH as root (default password: supersecurepass)
ssh root@localhost -p 2222
# Connect via SSH as created user (password from logs)
ssh developer@localhost -p 2222
# Or with custom port mapping
ssh root@localhost -p <your-port>
ssh developer@localhost -p <your-port># View container logs to see all passwords
docker logs ssh-container | grep "password"
# Access the root password log file directly
docker exec ssh-container cat /data/logs/root-password.log
# Access the user passwords log file directly
docker exec ssh-container cat /data/logs/user-passwords.log| Variable | Default | Description |
|---|---|---|
ROOT_PASWD |
supersecurepass |
Root user password. Set to password to auto-generate |
USER |
"" |
Username to create. If empty, no user is created |
USER_PASWD |
"" |
User password. Set to password to auto-generate, or specify custom password |
USER_IN_SUDO |
"" |
Set to true to grant sudo privileges to created user |
| Port | Description |
|---|---|
| 22 | SSH server port |
| Path | Description |
|---|---|
/data/logs/ |
Log files including root and user password logs |
/data/conf/ |
Configuration files |
/data/run/ |
Runtime files (PIDs, sockets) |
The container supports multiple password and user configuration modes:
| Mode | Configuration | Description |
|---|---|---|
| π Default | No env variable | Uses supersecurepass |
| π― Custom | ROOT_PASWD=mypassword |
Set your own password |
| π² Auto-Generated | ROOT_PASWD=password |
Random 16-character password |
| Mode | Configuration | Description |
|---|---|---|
| π« No User | No USER variable |
Only root user available |
| π€ Standard User | USER=username |
Create user with auto-generated password |
| π Custom Password User | USER=username USER_PASWD=mypassword |
Create user with custom password |
| π² Auto-Generated User | USER=username USER_PASWD=password |
Create user with auto-generated password |
| π Sudo User | USER=username USER_IN_SUDO=true |
Create user with sudo privileges |
| π§ Sudo + Custom Password | USER=username USER_PASWD=mypassword USER_IN_SUDO=true |
Create user with custom password and sudo privileges |
π Password Logging: All passwords are logged to:
- Container stdout (visible in
docker logs)/data/logs/root-password.logfor root password/data/logs/user-passwords.logfor user passwords
# Pull and run for development
docker pull polinux/ssh-ubuntu22
docker run -d -p 2222:22 --name dev-ssh polinux/ssh-ubuntu22
# Get the password
docker logs dev-ssh | grep "Root password"
# Connect via SSH
ssh root@localhost -p 2222# Run with secure custom password
docker run -d -p 2222:22 --name prod-ssh \
-e ROOT_PASWD=my-secure-password-123 \
--restart unless-stopped \
polinux/ssh-ubuntu22# Run with dedicated developer user having sudo privileges and custom password
docker run -d -p 2222:22 --name dev-ssh \
-e USER=developer \
-e USER_PASWD=my-dev-password \
-e USER_IN_SUDO=true \
--restart unless-stopped \
polinux/ssh-ubuntu22
# Connect as developer user with known password
ssh developer@localhost -p 2222# Run with developer user having auto-generated password
docker run -d -p 2222:22 --name dev-auto-ssh \
-e USER=developer \
-e USER_PASWD=password \
-e USER_IN_SUDO=true \
--restart unless-stopped \
polinux/ssh-ubuntu22
# Get user password from logs
docker logs dev-auto-ssh | grep "User.*password set to"
# Or get from password file
docker exec dev-auto-ssh cat /data/logs/user-passwords.log
# Connect as developer user
ssh developer@localhost -p 2222# Run with persistent data volume
docker run -d -p 2222:22 --name ssh-persistent \
-v ssh-data:/data \
--restart unless-stopped \
polinux/ssh-ubuntu22
# Access logs from volume
docker run --rm -v ssh-data:/data alpine \
cat /data/logs/root-password.log# Clone repository and use docker-compose
git clone https://github.com/pozgo/docker-ssh-ubuntu22.git
cd docker-ssh-ubuntu22
# Run default container
docker-compose up -d
# View logs to get password
docker-compose logs ssh-ubuntu22 | grep "Root password"
# Connect via SSH
ssh root@localhost -p 2222
β οΈ Important Security Information
| Description | |
|---|---|
| π§ͺ Development Use | Container configured for development/testing purposes |
| π€ Root Login | SSH permits root login for convenience |
| π Production Keys | Consider using SSH keys instead of passwords for production |
| π Password Logging | All passwords are logged in plain text for convenience |
| π§ Passwordless Sudo | Created users with sudo privileges have passwordless access |
| π Fresh Keys | SSH host keys are regenerated on each build |
# Check if SSH service is running
docker exec ssh-container supervisorctl status sshd
# View SSH logs for errors
docker exec ssh-container cat /data/logs/sshd.log
# Restart SSH service if needed
docker exec ssh-container supervisorctl restart sshd# Check initialization logs for root password
docker logs ssh-container | grep SSH-INIT
# Check initialization logs for user creation
docker logs ssh-container | grep USER-INIT
# Check password log files directly
docker exec ssh-container cat /data/logs/root-password.log
docker exec ssh-container cat /data/logs/user-passwords.log
# List all log files
docker exec ssh-container ls -la /data/logs/# Use different port mapping
docker run -d -p 2223:22 --name ssh-container polinux/ssh-ubuntu22
ssh root@localhost -p 2223
# Or find what's using the port
sudo lsof -i :2222# Check if user was created successfully
docker exec ssh-container id testuser
# Check sudo configuration for user
docker exec ssh-container cat /etc/sudoers.d/testuser
# Check user groups
docker exec ssh-container groups testuser
# Test sudo access
docker exec ssh-container su - testuser -c "sudo whoami"Available Resources:
- π³ Docker Hub: polinux/ssh-ubuntu22
- π Source Code: github.com/pozgo/docker-ssh-ubuntu22
- π Issues: Report bugs & feature requests
We welcome contributions! Here's how you can help:
- π΄ Fork the repository on GitHub
- πΏ Create a feature branch (
git checkout -b feature/amazing-feature) - βοΈ Make your changes
- π Commit your changes (
git commit -m 'Add amazing feature') - π€ Push to the branch (
git push origin feature/amazing-feature) - π Submit a pull request
This container is built on the excellent polinux/ubuntu22-supervisor base image.
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Przemyslaw (Ozzy) Ozgo
This project follows the same license as the base image polinux/ubuntu22-supervisor.
Made with β€οΈ by the Polinux Team
β Star us on GitHub if this project helped you!