Skip to content

Instantly share code, notes, and snippets.

@andycandy-de
Last active November 21, 2024 22:31
Show Gist options
  • Save andycandy-de/dafa4e83fbce94a61a570a1202b4acaa to your computer and use it in GitHub Desktop.
Save andycandy-de/dafa4e83fbce94a61a570a1202b4acaa to your computer and use it in GitHub Desktop.
Hidden OpenSSH Server

Just an example of how to launch a hidden OpenSSH server, which can be used to manage your internal infrastructure - either as a primary solution or as a backup to a VPN server.

hidden OpenSSH server

services:
  hidden-service:
    image: goldy/tor-hidden-service:latest
    links:
      - openssh-server
    depends_on:
      openssh-server:
        condition: service_started
    environment:
      SSH_TOR_SERVICE_HOSTS: 22:openssh-server:2222
      SSH_TOR_SERVICE_VERSION: '3'
      SSH_TOR_SERVICE_KEY: |
        PT0gZWQyNTUxOXYxLXNlY3JldDogdHlwZTAgPT0AAACArobDQYyZAWXei4QZwr++
        j96H1X/gq14NwLRZ2O5DXuL0EzYKkdhZSILY85q+kfwZH8z4ceqe7u1F+0pQi/sM
    restart: unless-stopped

  openssh-server:
    image: lscr.io/linuxserver/openssh-server:latest
    environment:
      PUID: 1000
      PGID: 1000
      PUBLIC_KEY_DIR: /config/public_key_dir
      SUDO_ACCESS: false
      PASSWORD_ACCESS: false
      USER_NAME: ssh
    volumes:
      - ./openssh-server/config:/config
    restart: unless-stopped

Connect to the hidden OpenSSH server securely using SSH over Tor, which can be achieved with torsocks. For example:

torsocks

services:
  torsocks:
    image: shpaker/torsocks:latest
    ports:
      - 9050:9050
ssh ssh@rhwe1f76c8ggw4jxldcn0zkc63c3htz05yk1uapat8kds3seze51zioq.onion -o "ProxyCommand=nc -X 5 -x 127.0.0.1:9050 %h %p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment