This project contains a Dockerfile and a build script to create and run an SSH server container based on Ubuntu. It allows you to easily set up an SSH server inside a Docker container.
To get started, follow the steps below:
- Clone this repository to your local machine.
- Rename the
.env.example
file to.env
and update the values ofSSH_USER
andSSH_PWD
with your desired SSH username and password. - Open a terminal and navigate to the project directory.
To build the Docker image, run the build.sh
script with the container name as first argument:
./build.sh <CONTAINER_NAME>
The script will read the values from the .env
file and build the Docker image with the provided SSH username and password.
After the Docker image is built, you can run the container using the following command:
docker run -it -d -p 22:22 --name <CONTAINER_NAME> <IMAGE_NAME>
Replace <CONTAINER_NAME>
with the desired name for your container and <IMAGE_NAME>
with the name of the Docker image.
To connect to the SSH server running inside the container, you can use an SSH client such as OpenSSH. Use the following command:
ssh -p 22 <SSH_USER>@<CONTAINER_IP>
Replace <SSH_USER>
with the SSH username you set in the .env
file, and <CONTAINER_IP>
with the IP address of the running container. You can obtain the IP address by running docker inspect <CONTAINER_NAME>
.