Skip to main content

SSH in your container

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

Modifying your dockerfile#

We will build the docker container using a different Docker Dockerfile in this version.

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 the server start.

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 tests and log into your container easily using the Edgegap infrastructure.

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

  2. Create a deployment using the new version you just created

  3. Once you have the service running (Ready), look in your deployment information. You will see the external port mapping of port 22.

  4. You can use Putty and connect using the FQDN of the deployment or Ip & the port mapping used

  5. The User name and password that you configured.