gosshtun

package module
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 18 Imported by: 0

README

go-sshtun

ssh tunnel via http, socks, support set pac or global system proxy

useage

quick start
docker run --rm --network host epurs/sshtun:lastest
download from release
# sshtun --help
  -d, --debug                   debug mode
  -h, --host string             ssh server address, like "192.168.50.220:2222"
  -i, --identitykey string      identity key file
  -k, --identitykeydir string   identity key dir
  -l, --listen string           service listing on (default "127.0.0.1:1080")
  -P, --pac string              enable pac. need a pac url, like "http://www.example.com/my.pac", or use embedded rules(gfw, tiny)
  -p, --password string         ssh password
  -S, --sysproxy                enable system proxy
  -t, --timeout duration        timeout (default 10s)
  -u, --user string             ssh user
docker run
# docker run --rm epurs/sshtun:lastest --help

# docker run --rm --network host -e "USER=root" -e "HOST=epurs.com" -e "PASSWORD=123456" -E "LISTEN=0.0.0.0:1080" epurs/sshtun:lastest

docker run -d --name sshtun1080 \
--restart unless-stopped \
-p 1080:1080 \
-v /Users/fimreal/.ssh:/root/.ssh \
epurs/sshtun:lastest \
-h epurs.com \
-uroot \
-i /root/.ssh/id_ed25519 \
-l 0.0.0.0:1080

reference

https://github.com/ejunjsh/goproxy https://github.com/scchenyong/sshtunnel/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SSHConfig

type SSHConfig struct {
	// ssh server address
	RemoteAddr string
	// ssh user
	User string
	// ssh password
	Password string
	// private key file
	IdentityKey string
	// ssh config dir
	IdentityKeyDir string
	// Timeout: 10s
	Timeout time.Duration
}

隧道配置

func DefaultSSHConfig

func DefaultSSHConfig() *SSHConfig

func (*SSHConfig) NewSSHClient

func (c *SSHConfig) NewSSHClient() (*ssh.Client, error)

func (*SSHConfig) ParseIdentityKey

func (c *SSHConfig) ParseIdentityKey() []ssh.AuthMethod

从私钥文件创建 SSH 认证方法

func (*SSHConfig) SSHPassword

func (c *SSHConfig) SSHPassword() ssh.AuthMethod

func (*SSHConfig) SetSSHHost

func (c *SSHConfig) SetSSHHost() string

func (*SSHConfig) SetSSHUser

func (c *SSHConfig) SetSSHUser() string

type SSHTun

type SSHTun struct {
	Client        *ssh.Client
	ListenAddr    string
	TotalUpload   int64
	TotalDownload int64
}

func NewSSHTun

func NewSSHTun(c *SSHConfig) (*SSHTun, error)

func (*SSHTun) Close

func (st *SSHTun) Close()

func (*SSHTun) DisableSystemProxy

func (st *SSHTun) DisableSystemProxy()

func (*SSHTun) PacInspect

func (st *SSHTun) PacInspect() string

func (*SSHTun) PacOff

func (st *SSHTun) PacOff()

func (*SSHTun) PacOn

func (st *SSHTun) PacOn(rule string) (ok bool)

func (*SSHTun) Serve

func (st *SSHTun) Serve()

func (*SSHTun) Stat

func (st *SSHTun) Stat()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL