All Projects → rgzr → sshtun

rgzr / sshtun

Licence: GPL-3.0 License
Go package to create SSH tunnels

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to sshtun

Mole
CLI application to create ssh tunnels focused on resiliency and user experience.
Stars: ✭ 1,520 (+2351.61%)
Mutual labels:  ssh, forwarding, ssh-tunnel
rsp
Rapid SSH Proxy
Stars: ✭ 223 (+259.68%)
Mutual labels:  ssh, ssh-tunnel
tmuxpair
Command line script for setting up a temporary tmux session for pair programming
Stars: ✭ 34 (-45.16%)
Mutual labels:  ssh
shim
The Userify Shim (cloud agent)
Stars: ✭ 57 (-8.06%)
Mutual labels:  ssh
sshlatex
A collection of hacks to efficiently run LaTeX via ssh
Stars: ✭ 32 (-48.39%)
Mutual labels:  ssh
lobbyboy
A lobby boy will create a VPS server when you need one, and destroy it after using it.
Stars: ✭ 212 (+241.94%)
Mutual labels:  ssh
switch-ssh-go
A packaged SSH library for switches (huawei,h3c,cisco)
Stars: ✭ 53 (-14.52%)
Mutual labels:  ssh
FastTunnel
expose a local server to the internet. 高性能跨平台的内网穿透解决方案 远程内网计算机 域名访问内网站点 反向代理内网服务 端口转发 http代理
Stars: ✭ 815 (+1214.52%)
Mutual labels:  ssh
ssh2.nim
Async SSH, SCP and SFTP client for Nim, using libssh2 wrapper [WIP]
Stars: ✭ 17 (-72.58%)
Mutual labels:  ssh
rustica
An SSHCA that uses a standard Yubikey to issue new host and user certificates.
Stars: ✭ 24 (-61.29%)
Mutual labels:  ssh
tarssh
A simple SSH tarpit inspired by endlessh
Stars: ✭ 98 (+58.06%)
Mutual labels:  ssh
piv-agent
An SSH and GPG agent which you can use with your PIV hardware security device (e.g. a Yubikey).
Stars: ✭ 31 (-50%)
Mutual labels:  ssh
cl
Concurrently run commands across multiple servers via SSH
Stars: ✭ 45 (-27.42%)
Mutual labels:  ssh
remotemoe
tunnels to localhost and other ssh plumbing
Stars: ✭ 112 (+80.65%)
Mutual labels:  ssh
backup-action
🗄️ Github Action to backup MySQL, MongoDB and PostgreSQL databases
Stars: ✭ 27 (-56.45%)
Mutual labels:  ssh
guacamole-auth-jwt
Guacamole authentication extension based on JWT.
Stars: ✭ 28 (-54.84%)
Mutual labels:  ssh
ssh
golang ssh lib simple for use
Stars: ✭ 15 (-75.81%)
Mutual labels:  ssh
piping-ssh-web
SSH over HTTPS via Piping Server on Web browser
Stars: ✭ 60 (-3.23%)
Mutual labels:  ssh
Kali-Linux-Tools-Interface
Graphical Web interface developed to facilitate the use of security information tools.
Stars: ✭ 169 (+172.58%)
Mutual labels:  ssh
AppToolkit
🐘 The Front-end Env Toolkit(前端环境管理工具)
Stars: ✭ 411 (+562.9%)
Mutual labels:  ssh

sshtun

GoDoc

sshtun is a Go package that provides a SSH tunnel with port forwarding supporting:

  • TCP and unix socket connections
  • Password authentication
  • Un/encrypted key file authentication
  • ssh-agent based authentication

By default it reads the default linux ssh private key location $HOME/.ssh/id_rsa and fallbacks to using ssh-agent, but a specific authentication method can be set.

Installation

go get github.com/rgzr/sshtun

Example

package main

import (
    "log"
    "time"

    "github.com/rgzr/sshtun"
)

func main() {
    // We want to connect to port 8080 on our machine to access port 80 on my.super.host.com
    sshTun := sshtun.New(8080, "my.super.host.com", 80)

    // We enable debug messages to see what happens
    sshTun.SetDebug(true)

    // We set a callback to know when the tunnel is ready
    sshTun.SetConnState(func(tun *sshtun.SSHTun, state sshtun.ConnState) {
        switch state {
        case sshtun.StateStarting:
            log.Printf("STATE is Starting")
        case sshtun.StateStarted:
            log.Printf("STATE is Started")
        case sshtun.StateStopped:
            log.Printf("STATE is Stopped")
        }
    })

    // We start the tunnel (and restart it every time it is stopped)
    go func() {
        for {
            if err := sshTun.Start(); err != nil {
                log.Printf("SSH tunnel stopped: %s", err.Error())
                time.Sleep(time.Second) // don't flood if there's a start error :)
            }
        }
    }()

    // We stop the tunnel every 20 seconds (just to see what happens)
    for {
        time.Sleep(time.Second * time.Duration(20))
        log.Println("Lets stop the SSH tunnel...")
        sshTun.Stop()
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].