This Docker image provides an Ubuntu 24.04 base with SSH server enabled. It allows you to easily create SSH-accessible containers via SSH keys or with a default username and password.
To get started, clone the GitHub repository containing the Dockerfile and scripts:
git clone https://github.com/qiaodapei/docker-ubuntu-ssh
cd docker-ubuntu-ssh
Build the Docker image from within the cloned repository directory:
docker build -t docker-ubuntu-ssh:latest .
You can use the provided docker-compose.yml to easily set up and run the container:
Update the docker-compose.yml file with your desired configuration. Key configurable options include:
PUID and PGID to set the user and group IDs.ALLOWED_IPS to restrict SSH access to specific IPs.PUBLIC_KEY to specify an SSH public key.USER_NAME and USER_PASSWORD to set the default username and password.TZ to configure the time zone.Start the container using the following command:
docker-compose up -d
This command will create and run the container in detached mode.
The following example docker-compose.yml creates an SSH-accessible container with a specific user and password:
services:
openssh-server:
image: docker-ubuntu-ssh:latest
container_name: openssh-server
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- ALLOWED_IPS="[email protected],[email protected]"
- PUBLIC_KEY=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDQA7Z34k+
- SUDO_ACCESS=true
- PASSWORD_ACCESS=true
- USER_PASSWORD=password
- USER_NAME=user01
ports:
- 1122:22
restart: unless-stopped
Once the container is running, you can SSH into it using the following command:
ssh -p 1122 user01@localhost
1122 with the port specified in the docker-compose.yml file.user01 with the username configured in the USER_NAME environment variable.PASSWORD_ACCESS to false if using public key authentication.ALLOWED_IPS variable.PUBLIC_KEY environment variable to specify authorized SSH keys.To stop and remove the container, use:
docker-compose down
This Docker image is provided under the MIT License.
Content type
Image
Digest
sha256:01abdee21…
Size
159.7 MB
Last updated
almost 2 years ago
docker pull qiaodapei/docker-ubuntu-ssh