GithubHelp home page GithubHelp logo

sshtuntap's Introduction

sshtuntap

Linux TUN/TAP using the openssh and Python3

This package comes with two command line interfaces:

  • ssh-tuntap-server
  • ssh-tuntap-client

this tutorial show's how to use this project:

Tutorial

Currently only point-to-point (tun) layer-3 tunneling is supported.

Install

You have to install this package on both client and server.

sudo -H pip3 install sshtuntap

Or

sudo -H pip3 install git+https://github.com/pylover/sshtuntap.git

Bash auto completion

ssh-tuntap-server completion install   # On server
ssh-tuntap-client completion install   # On client

Open new bash instance to perform changes.

Help?

ssh-tuntap-server --help
ssh-tuntap-client --help

Server setup

The server cli stands for setup network, add, delete and list users. this is just a utility to perform user and tuntap interface management and ip address assignment.

OpenSSH Server

Enable ssh tunneling on the server by editing the /etc/ssh/sshd_config and ensure the line:

PermitTunnel yes

Or

PermitTunnel point-to-point

see man 5 sshd_config for more info.

Restart the ssh server to perform the changes.

service ssh restart

Create Network and systemd service

sudo ssh-tuntap-server install

Or

sudo ssh-tuntap-server install 192.168.22.0/24

you may use uninstall sub-command to remove systemd service.

sudo ssh-tuntap-server uninstall

Add foo host

You have to create the server user mannualy (depends on your distro).

Here I'm using ubuntu server 18.04. and assume the server's hostname is example.com.

Run these commands on the server:

sudo adduser foo

Then use this command to create /home/foo/.ssh/tuntap.yml:

sudo ssh-tuntap-server add foo

Client

Client command line stands for fetch host configuration from the server and perform connection using the ssh -w.

ssh-copy-id [email protected]
ssh-tuntap-client setup [email protected]

Use this to connect:

sudo ssh-tuntap-client connect

Nat

Edit /etc/sysctl.conf on the server to enable ip forwarding.

net.ipv4.ip_forward = 1

Run sysctl -p to refresh with the new configuration

sudo sysctl -p

Configure NAT

sudo iptables -tnat -APOSTROUTING -s192.168.22.0/24 -jMASQUERADE

iptables persistency

sudo apt install iptables-persistent netfilter-persistent

sshtuntap's People

Contributors

atipy avatar babakhani avatar majidghassaei avatar pylover avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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