Access your Podman container using SSH
Objective π
The objective of this tutorial is to show how to setup an Ubuntu-based Podman container with an SSH server.
Description π
In many scenarios, itβs important to provide an isolated environment where end-users can run applications freely, while ensuring the host system remains safe and unaffected. Containers are perfect for this: they let the user work inside a dedicated space without risking misconfigurations or disruptions on the host.
The challenge, however, is that accessing a container usually requires logging into the host machine first, which is not always practical.
In this tutorial, youβll learn how to enable direct SSH access into a container. This way, users can interact with the container environment as if it were a standalone system.
Prerequisites π οΈ
- A WebPanel (WP) or TouchController (TC) device
- Basic knowledge of SSH
- Basic knowledge of podman and containers
- Basic knowledge of Linux
Steps πͺ
-
Connect to the device via SSH using the
2. Navigate to the persistent folderuseraccount:/data/user: -
Create a dedicated folder for the tutorial:
-
Create a
Dockerfilefile with the following content:This# Base Ubuntu image FROM ubuntu:latest # Prevent interactive prompts during package install ENV DEBIAN_FRONTEND=noninteractive # Install OpenSSH server and sudo RUN apt-get update && apt-get install -y \ openssh-server \ sudo \ && rm -rf /var/lib/apt/lists/* # Create SSH directory RUN mkdir /var/run/sshd # Create a non-root user `user` with password `123456` # and sudo privileges # -m: create `user` home directory (/home/user) # -s: set default shell for `user` to bash RUN useradd -ms /bin/bash user \ && echo "user:123456" | chpasswd \ && echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # Harden SSH config: disable root login, but allow password auth for user RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config \ && sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config # Expose SSH port EXPOSE 22 # Start SSH service CMD ["/usr/sbin/sshd", "-D"]Dockerfileprovides a base Ubuntu image with a non-root user and an SSH server that runs as soon as the container is started -
Create a
This compose file builds the previously created Dockerfile and runs it mapping the container port 22 (default SSH port) to the port 8022 of the host. This way, it won't collide with the already open SSH port of the host panelpodman-compose.ymlfile with the following content: -
Run the container using the following command:
-
Connect to the container with SSH using the following command:
![]()