Skip to main content

SSH in your container

Note, Edgegap is not recommending having SSH service accessible in your production deployments.

Modifying your dockerfile#

In this version, we will build the docker container using a different Docker Dockerfile.

We will need to install the OpenSSH service and enable it Create a User and a password to connect to your server.

In a container running on Alpine, merge the following

RUN apk --update add --no-cache openssh bash
RUN sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config
RUN echo "tester:$ecureP@ss" | chpasswd

In a container running on Ubuntu, add the following.

RUN apt-get update
RUN apt-get install openssh-server sudo -y
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000
RUN echo 'tester:$ecureP@ss' | chpasswd

In your entrypoint, you will need to add the following command

service ssh start

We suggest testing the deployment locally, using the docker run command to test that the server is starting normally

Once tested, you can push your new version on the container repository

In Arbitrium#

We suggest having a version called -dev or something that would make sense in your service. By doing so, you will have the option to do some test and log into your container easily using the Edgegap infrastructure.

Create a new version of your app, adding the Expose TCP Port 22

Create a deployment using the new version you just created \ Once you have the service running (Ready), look in your deployment information, you will see the external port mapping of port 22. \

You can use Putty and connect using the FQDN of the deployment or Ip & the port mapping used \ The User name and password that you configured