HUB
Sign inSign up

ariadata/ssh-tunnel-socket-mapper

By ariadata

•Updated over 2 years ago

ssh-tunnel with socket mapping inside a container to a dockerhost

Image
0

379

ariadata/ssh-tunnel-socket-mapper repository overview

⁠ssh-tunnel with socket mapping inside a container to a dockerhost

⁠Step 1:

Create ssh-keys dir and generate valid pair keys in local system

mkdir -m 700 ./ssh-keys
ssh-keygen -t rsa -b 4096 -C "my-remote-access" -f ./ssh-keys/id_rsa
⁠Step 2:

Connect and add your public key to server

# in this example
# SSH_HOST_IP is 1.2.3.4
# SSH_PORT is 22
# SSH_USER is ssh_user
ssh-copy-id -i ./ssh-keys/id_rsa.pub -p 22 [email protected]
# type yes then type your ssh password
exit
⁠Step 3 :

Create (or modify) .env file with something like:

COMPOSE_PROJECT_NAME="my-socket-tunnel"
UID=1000
GID=1000
SSH_HOST="SSH_HOST_IP"
SSH_PORT="22"
SSH_USER="ssh_user"

REMOTE_SOCKET_PATH="/home/user/remote-folder/test.socket"
LOCAL_SOCKET_NAME="test.socket"
⁠Step 4:

Create docker-compose.yaml file with contents like:

version: '3.7'

services:
  ssh-tunnel-mysocket:
    image: 'ariadata/ssh-tunnel-socket-mapper:latest'
    container_name: sshtunnel_mysocket
    restart: unless-stopped
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    volumes:
      - './ssh-keys:/root/ssh-keys'
    environment:
      PUID: '${UID:-1000}'
      PGID: '${GID:-1000}'
      SSH_HOST: '${SSH_HOST}'
      SSH_PORT: '${SSH_PORT}'
      SSH_USER: '${SSH_USER}'
      REMOTE_SOCKET_PATH: '${REMOTE_SOCKET_PATH}'
      LOCAL_SOCKET_NAME: '${LOCAL_SOCKET_NAME}'
    
⁠Step 5:

Use REMOTE_SOCKET_PATH for remote socket path address MUST FULL PATH : /home/user/sockets/test.socket

Use LOCAL_SOCKET_NAME to outside of your docker-compose like : ./sockets/test.socket

⁠Enjoy!

Tag summary

Content type

Image

Digest

sha256:eb6b3b909…

Size

35.2 MB

Last updated

over 2 years ago

docker pull ariadata/ssh-tunnel-socket-mapper