Coder Social home page Coder Social logo

sshsrv's Introduction

sshsrv

sshsrv is a simple program to lookup and connect to an SSH endpoint via DNS SRV records.

Why SRV Records?

Consider the scenario where there are multiple hosts NATted behind a single IPv4 address. There are two usual methods for handling connecting to these internal hosts from outside the network:

  1. Port-forward each internal host's SSH port to some high port on the gateway device; or
  2. Forward port 22 to a single, internal "jump-host" and either manually connect to other internal hosts or proxy (using the -W option to ssh(1)) from there.

The first option requires you to remember which external port you've assigned to which internal host. The second option requires an extra hop between you and your internal hosts. Using SRV records instead means that you can connect directly to your internal machines just like the first option above, and provides the added benefit of a mechanism to look up which port you've assigned to each internal server.

Example

Say you have a home network with multiple hosts, but like most of the world you only have one external IPv4 address. Set up a SRV record like the following:

$ dig +short _ssh._tcp.myhost.mydomain.com SRV
1 1 22029 gateway.mydomain.com.

Using sshsrv, when you want to connect to myhost.mydomain.com it will look up this SRV record, which will tell sshsrv to actually connect to gateway.mydomain.com on port 22029 instead. (If no SRV record exists, sshsrv will simply pass the hostname directly to ssh(1).)

Usage

sshsrv strives to accept the same options that the ssh(1) command does, so that it can be a drop-in replacement for the ssh(1) command. If there is a valid flag that isn't supported, please open an issue or PR!

Installation

You can download the latest pre-built releases here.

Alternatively, you can install it with Go 1.17 or higher like so:

$ go install github.com/Crosse/sshsrv@latest

Why not just submit a patch to OpenSSH?

Using a wrapper allows the user to use whatever version of ssh(1) is installed on their system, instead of being an OpenSSH-only addition.

Questions, Comments, Suggestions?

Submit a pull request!

sshsrv's People

Contributors

crosse avatar dependabot-preview[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.