Ubuntu Lab Docker Images with Web Terminal

Ubuntu 18.04 in the browser

Using a combination of Docker, Ubuntu, SSHD, TTYD and SupervisorD, I’ve created some handy docker images, available via Docker Hub that can be used for quickly spinning up Ubuntu testing/lab systems.

The images are preconfigured with both SSHD and TTYD (for Web browser access) and can be configured further for a custom user account and ssh keys.

Overview

Uses supervisord to run both sshd and ttyd in a convenient container.

sshd provides ssh connectivity. The daemon has been configured to allow root login and ssh keys can be autoconfigured on startup.

ttyd provides a web based terminal, the image has also been customised to allow direct root login

Default user of guest/guest is provided, can be overridden in the docker file or via environment variables

Version Tags

This image provides various versions that are available via tags. latest tag usually provides a known stable version. Others are considered under development and caution must be exercised when using them.

Tag Description
latest Ubuntu 18.04 Bionic Beaver
xenial Ubuntu 16.04 Xenial Xerus
bionic Ubuntu 18.04 Bionic Beaver
eoan Ubuntu 19.10 Eoan Ermie
focal Ubuntu 20.04 Focal Fossa

Examples (change :latest to the corresponding tag)

Run with ssh port 23 (host) forwarding to 22 (container), can be accessed with users guest/guest
or root/root

docker run -p 23:22 spurin/docker-lab-linux-sshd-supervisord-ttyd:latest

Run with ttyd port 7681 (host) forwarding to 7681 (container), can be accessed via http://localhost:7681

docker run -p 7681:7681 spurin/docker-lab-linux-sshd-supervisord-ttyd:latest

Run with both sshd and ttyd forwarded

docker run -p 23:22 -p 7681:7681 spurin/docker-lab-linux-sshd-supervisord-ttyd:latest

Change guest/guest to james/james

# Create target dir, example uses /Users/james/lab/config
echo james > /Users/james/lab/config/guest_name
echo james > /Users/james/lab/config/guest_passwd
echo '/bin/bash' > /Users/james/lab/config/guest_shell

docker run -p 23:22 -p 7681:7681 -v /Users/james/lab/config:/config spurin/docker-lab-linux-sshd-supervisord-ttyd:latest

Use a volume for the users homedir

# Create target dirs, example uses /Users/james/lab/config and /Users/james/lab/homedir
echo james > /Users/james/lab/config/guest_name
echo james > /Users/james/lab/config/guest_passwd
echo '/bin/bash' > /Users/james/lab/config/guest_shell

docker run -p 23:22 -p 7681:7681 -v /Users/james/lab/config:/config -v /Users/james/lab/james_homedir:/home/james spurin/docker-lab-linux-sshd-supervisord-ttyd:latest

Specify SSH keys for user and root

# Create target dirs, example uses /Users/james/lab/config and /Users/james/lab/homedir
echo james > /Users/james/lab/config/guest_name
echo james > /Users/james/lab/config/guest_passwd
echo '/bin/bash' > /Users/james/lab/config/guest_shell
ssh-keygen -b 2048 -t rsa -f /Users/james/lab/config/guest_ssh -q -N ""
ssh-keygen -b 2048 -t rsa -f /Users/james/lab/config/root_ssh -q -N ""

docker run -p 23:22 -p 7681:7681 -v /Users/james/lab/config:/config -v /Users/james/lab/james_homedir:/home/james spurin/docker-lab-linux-sshd-supervisord-ttyd:latest
Share