SSH Bridge£ project provides a bridge over SSH using Docker containers. It includes two components: the SSH client and the SSH server.
- Docker
- Docker Compose
- Make Utility
We use make commands for various operations in this project. Below is a brief description of each command.
- Building the Docker image:
make buildThis command is used to build the Docker image.
- Pushing the Docker image:
make pushThis command pushes the built Docker image to the specified repository.
- Pulling the Docker image:
make pullThis command pulls the image from the specified repository.
- Generating SSH Keys:
make generate-ssh-keysThis command generates new SSH keys.
- Launching the SSH Server:
make serverThis command starts the SSH server.
- Launching the SSH Client with a local docker container:
make proxyThis command starts the SSH tunnel from a local docker container. It can be used if SSH is not installed locally.
- 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}- Cleaning up:
make cleanThis 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_usernamePlease ensure that you have proper permissions set for your SSH files/directory.
Enjoy using SSH Bridge!