Giter Site home page Giter Site logo

autossh-tunnel's Introduction

autossh-tunnel

Setup and keep alive ssh tunnels to remote sites using autossh, screen.

Requirements

  • autossh
  • screen

How it works

  1. Sites to tunnel to are configured in ~/.ssh/config: Host declarations that start with 'autossh-' in the name are detected as candidates for tunnel sites. Example:

     Host autossh-HOSTNAME
     Hostname HOSTNAME
     User USER
     RemoteForward 8022 localhost:22
     IdentityFile ~/.ssh/autossh-id_rsa
    
  2. ssh-keygen.sh: helper script to generate an SSH key without passphrase. Note: for added security, the public key is configured with the following options:

     command="/bin/false",no-agent-forwarding,no-X11-forwarding,no-pty
    
  3. ssh-copy-id.sh: helper script to install SSH key in ~/.ssh/authorized_keys on each of the detected tunnel sites

  4. setup.sh:

    Print the details of the detected setup:

    • SSH key that will be used with autossh
    • Detected tunnel sites in ~/.ssh/config
    • Confirmed tunnel sites (accepting the SSH key)

    Print the steps to complete the configuration.

    Print tips how to test the configuration.

  5. autossh.sh: run autossh for each detected site in an independent screen session, unless already running

  6. Add to crontab a line like this to periodically run autossh.sh:

     0 * * * * AUTOSSH_PORT=0 $PWD/autossh.sh
    

How to install

Simply run ./setup.sh and follow the steps. This script does not do anything. It only tells you the configuration it detected and gives you the steps you need to follow to complete the configuration.

How to uninstall

  • Remove any cron jobs running autossh.sh
  • ./stop.sh to stop any running autossh and screen instances
  • Login to each tunnel site and manually remove the script's SSH key from ~/.ssh/authorized_keys

autossh-tunnel's People

Contributors

janosgyerik avatar

Watchers

 avatar  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.