Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aoudiamoncef/ubuntu-sshd
This project provides a way to create a Docker image based on an official Ubuntu Image with an SSH server (SSHD) enabled
https://github.com/aoudiamoncef/ubuntu-sshd
docker docker-image dockerhub ssh ssh-server ubuntu2404lts
Last synced: 7 days ago
JSON representation
This project provides a way to create a Docker image based on an official Ubuntu Image with an SSH server (SSHD) enabled
- Host: GitHub
- URL: https://github.com/aoudiamoncef/ubuntu-sshd
- Owner: aoudiamoncef
- License: mit
- Created: 2023-09-13T08:51:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-19T21:13:50.000Z (4 months ago)
- Last Synced: 2024-11-14T02:19:51.414Z (2 months ago)
- Topics: docker, docker-image, dockerhub, ssh, ssh-server, ubuntu2404lts
- Language: Shell
- Homepage:
- Size: 14.6 KB
- Stars: 19
- Watchers: 1
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Docker Image CI](https://github.com/aoudiamoncef/ubuntu-sshd/actions/workflows/ci.yml/badge.svg)](https://github.com/aoudiamoncef/ubuntu-sshd/actions/workflows/ci.yml)
[![Docker Image Deployment](https://github.com/aoudiamoncef/ubuntu-sshd/actions/workflows/cd.yml/badge.svg)](https://github.com/aoudiamoncef/ubuntu-sshd/actions/workflows/cd.yml)
[![Docker Pulls](https://img.shields.io/docker/pulls/aoudiamoncef/ubuntu-sshd.svg)](https://hub.docker.com/r/aoudiamoncef/ubuntu-sshd)
[![Maintenance](https://img.shields.io/badge/Maintained-Yes-green.svg)](https://github.com/aoudiamoncef/ubuntu-sshd)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.
## Usage
### Cloning the Repository
To get started, clone the GitHub [repository](https://github.com/aoudiamoncef/ubuntu-sshd) containing the Dockerfile and
scripts:```bash
git clone https://github.com/aoudiamoncef/ubuntu-sshd
cd ubuntu-sshd
```### Building the Docker Image
Build the Docker image from within the cloned repository directory:
```bash
docker build -t my-ubuntu-sshd:latest .
```### Running a Container
To run a container based on the image, use the following command:
```bash
docker run -d \
-p host-port:22 \
-e SSH_USERNAME=myuser \
-e SSH_PASSWORD=mysecretpassword \
-e AUTHORIZED_KEYS="$(cat path/to/authorized_keys_file)" \
-e SSHD_CONFIG_ADDITIONAL="your_additional_config" \
-e SSHD_CONFIG_FILE="/path/to/your/sshd_config_file" \
my-ubuntu-sshd:latest
```- `-d` runs the container in detached mode.
- `-p host-port:22` maps a host port to port 22 in the container. Replace `host-port` with your desired port.
- `-e SSH_USERNAME=myuser` sets the SSH username in the container. Replace `myuser` with your desired username.
- `-e SSH_PASSWORD=mysecretpassword` sets the SSH user's password in the container. **This environment variable is
required**. Replace `mysecretpassword` with your desired password.
- `-e AUTHORIZED_KEYS="$(cat path/to/authorized_keys_file)"` sets authorized SSH keys in the container. Replace `path/to/authorized_keys_file` with the path to your authorized_keys file.
- `-e SSHD_CONFIG_ADDITIONAL="your_additional_config"` allows you to pass additional SSHD configuration. Replace
`your_additional_config` with your desired configuration.
- `-e SSHD_CONFIG_FILE="/path/to/your/sshd_config_file"` allows you to specify a file containing additional SSHD
configuration. Replace `/path/to/your/sshd_config_file` with the path to your configuration file.
- `my-ubuntu-sshd:latest` should be replaced with your Docker image's name and tag.### SSH Access
Once the container is running, you can SSH into it using the following command:
```bash
ssh -p host-port myuser@localhost
```- `host-port` should match the port you specified when running the container.
- Use the provided password or SSH key for authentication, depending on your configuration.### Note
- If the `AUTHORIZED_KEYS` environment variable is empty when starting the container, it will still launch the SSH server, but no authorized keys will be configured. You have to mount your own authorized keys file or manually configure the keys in the container.
- If `AUTHORIZED_KEYS` is provided, password authentication will be disabled for enhanced security.## License
This Docker image is provided under the [MIT License](LICENSE).