Skip to content

7d4b9/docker-ssh-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSH Bridge

SSH Bridge£ project provides a bridge over SSH using Docker containers. It includes two components: the SSH client and the SSH server.

IMG_1506

Prerequisites

  • Docker
  • Docker Compose
  • Make Utility

Usage

We use make commands for various operations in this project. Below is a brief description of each command.

  1. Building the Docker image:
make build

This command is used to build the Docker image.

  1. Pushing the Docker image:
make push

This command pushes the built Docker image to the specified repository.

  1. Pulling the Docker image:
make pull

This command pulls the image from the specified repository.

  1. Generating SSH Keys:
make generate-ssh-keys

This command generates new SSH keys.

  1. Launching the SSH Server:
make server

This command starts the SSH server.

  1. Launching the SSH Client with a local docker container:
make proxy

This command starts the SSH tunnel from a local docker container. It can be used if SSH is not installed locally.

  1. Launching the SSH Client from your machine directly

Add this to your .bashrc. You have to adjust some values like workspace/docker-ssh-bridge/id_rsa to where you did clone the current project

# Distant docker socket over ssh
export SSH_DOCKER_SERVER_HOST=bbrodriguez.example.org
export SSH_DOCKER_SERVER_PORT=21312
export SSH_DOCKER_SERVER_USER=devuser

# Expose distand dockerd socket locally with DOCKER_HOST
client_ssh_docker_tunnel_host=localhost
client_ssh_docker_tunnel_port=23750
# ssh docker tunnel creation if not exist
nc -z ${client_ssh_docker_tunnel_host} ${client_ssh_docker_tunnel_port}
if [ $? -ne 0 ] ; then
    # if private key exists use it directly
    if [ -f workspace/docker-ssh-bridge/id_rsa ] ; then
        ssh -i workspace/docker-ssh-bridge/id_rsa -NL ${client_ssh_docker_tunnel_host}:${client_ssh_docker_tunnel_port}:/var/run/docker.sock ${SSH_DOCKER_SERVER_USER}@${SSH_DOCKER_SERVER_HOST} -p ${SSH_DOCKER_SERVER_PORT} &
    fi
fi

export DOCKER_HOST=tcp://${client_ssh_docker_tunnel_host}:${client_ssh_docker_tunnel_port}
  1. Cleaning up:
make clean

This command deletes the generated SSH keys.

Use these commands as per your requirements.

Note: The REPOSITORY variable can be set to your Docker Hub username or any other registry where you wish to push your images. If not specified, it defaults to dbndev.

make push REPOSITORY=your_dockerhub_username

Please ensure that you have proper permissions set for your SSH files/directory.

Enjoy using SSH Bridge!

About

Provide local Docker socket access over VPN in Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published