Sign inSign up

papaux/ssh-slim

By papaux

•Updated 4 days ago

A minimal docker image for running SSH commands

Image
0

777

papaux/ssh-slim repository overview

⁠ssh-slim

A minimal docker image for running SSH commands based on alpine distribution. Perfect for integrating in a CI pipeline.

The image is available in docker hub⁠

⁠Usage

A private key needs to be provided to the container in the SSH_PRIVATE_KEY environment variable.

⁠docker run

For example, to laod the private key from a file:

docker run --rm -ti -e SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" papaux/ssh-slim ssh <user>@<host> ls

⁠Gitlab CI

Example of a deploy stage in .gitlab-ci.yml using this image.

The SSH private key is stored in the Gitlab project configuration as a secret with the name ${YOUR_GITLAB_SECRET_PRIVATE_KEY}

deploy to staging:
  stage: staging
  image: papaux/ssh-slim
  environment:
    name: staging
    url: https://staging.your-service.com
  only:
    - master
  variables:
    SSH_PRIVATE_KEY: ${YOUR_GITLAB_SECRET_PRIVATE_KEY}
    GIT_STRATEGY: none
  script:
    - ssh [email protected] git:from-image <your-app> <your-docker-image>

⁠Build

docker build -t ssh-slim --build-arg ALPINE_VERSION=3.13 .

⁠Limitations

Currently the image only supports ssh keys without passphrase.

⁠Docker Hub build hook

Instead of providing one Dockerfile per version, this image relies on the configured docker tag to fetch the corresponding alpine image version.

It will basically pick whatever "Docker Tag" is configured from the Build Rules. For instance:

example-docker-hub-docker-tag

Documentation about build hooks is really hard to find, especially what is the default build command in the hook.

These links can be useful to understand:

Tag summary

Content type

Image

Digest

sha256:5d171ce4b…

Size

12.1 MB

Last updated

4 days ago

docker pull papaux/ssh-slim