Giter Site home page Giter Site logo

bobquest33 / auto-ssh-tunnel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facerecog/auto-ssh-tunnel

0.0 2.0 0.0 4.71 MB

Automatic SSH Tunnel is a Python script which can be used to create a Reverse SSH Tunnel between multiple computers running Linux and a centralized server. Property of Facerecog Asia Pte. Ltd. and 26 Factorial

License: GNU General Public License v3.0

Python 100.00%

auto-ssh-tunnel's Introduction

 

     
 

Overview

Automatic SSH Tunnel is a Python script which can be used to create a Reverse SSH Tunnel between multiple computers running Linux and a centralized server.

Licensed under the MIT License - https://opensource.org/licenses/MIT

Features

  • Automatically configures and runs openssh to set-up a reverse ssh connection during boot-up

  • Automatically generates ssh keys

  • No need to store the server's password

  • Works with Debian-based systems, including Ubuntu

  • 3-step configuration wizard that requires less than 1 minute to set-up

System requirements

  • These instructions were tested on Ubuntu 15.10, Ubuntu 14.04.3, and Raspbian Jessie (Raspberry Pi)

  • The installation script automatically installs openssh-server with Apt


Animated Tutorial

   
 
 
 
 
 
   
 
 
 
 
 
 


Getting started

Download

Clone the latest repository version from Github (recommended):
$ git clone https://github.com/facerecog/auto-ssh-tunnel.git

Alternatively, download the .tar.gz file from the top of this page and unpack it:
$ wget https://github.com/facerecog/auto-ssh-tunnel/tarball/master -O - | tar -xz

Now cd into the newly extracted directory.

Installation

Additional instructions for Mac OS X Users

Go to:
System Preferences > Sharing. Turn on "Remote Login". Allow access for "All Users".
 

  1. Run configuration.py to specify the port, username, and IP address of the SSH server:
    $ python configure.py <port> <username> <ip address>

  2. Run the following command:
    $ sudo python setup.py install

The installation will proceed automatically. If successful, the output of all the commands should roughly show:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssh-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 118 not upgraded.
[*] Installing autossh client...
[*] Installing autossh as startup application...
mkdir: cannot create directory ‘.ssh’: File exists
yes: standard output: Broken pipe
yes: write error
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): priv_key already exists.
Overwrite (y/n)? [*] Copying SSH-Keys file over to server...
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
"<username>@<ip address>" 's password: 
Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ' "<username>@<ip address>" '"
and check to make sure that only the key(s) you wanted were added.

[*] Installing private keys inside protected folder...
yes: standard output: Broken pipe
yes: write error
[*] Moving autossh client into the /usr/local/bin/ directory...
[*] Moving private key to /etc/auto-ssh-tunnel/
mkdir: cannot create directory ‘/etc/auto-ssh-tunnel’: File exists
yes: standard output: Broken pipe
yes: write error

[*] We are now finished with the installation! Restart the client to complete the installation. To run autossh, input connect.py on the terminal.

How the script works

During installation, the script will automatically append the following lines to /etc/ssh/ssh_config:

ServerAliveInterval 30
ServerAliveCountMax 4

It will also append the following to /etc/ssh/sshd_config

ClientAliveInterval 30
ClientAliveCountMax 4

Upon boot, the client will run connect.py, which sets up a reverse ssh tunnel. The server may now ssh into the client even if the client resides behind a NAT firewall.


Verify that it works

  • From the client, ssh into your server:
    $ ssh <rootname>@<ip address>

  • Once in, connect back to your client:
    $ ssh <your username>@localhost -p <port number specified as above>

  • If successful, you have just ssh-ed back into your client. Congratulations and enjoy!


Reverse SSH Tunnel Diagram


Uninstall

To uninstall: $ sudo rm -rf /etc/init.d/connect.py /etc/auto-ssh-tunnel /usr/local/bin/connect.py /System/Library/StartupItems/auto-ssh-tunnel/


Support

If you want to support this project, please consider reaching out to me via [email protected]


Property of Facerecog Asia Pte. Ltd. and 26 Factorial

auto-ssh-tunnel's People

Contributors

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