Git Product home page Git Product logo

sshtunnel's Introduction

goSSHTunnel

SSH的的Port Forward,中文可以称为端口转发,是SSH的一项非常重要的功能。它可以建立一条安全的SSH通道,并把任意的TCP连接放到这条通道中。 Port Forward SSH, Chinese can be referred to as port forwarding, is a very important feature of SSH. It can establish a secure SSH channel, and put any TCP connection into this channel.

SSH端口映射

ssh -C -f -N -g -L 本地端口:目标IP:目标端口 用户名@目标IP ssh -C -f -N -g -L 5678:10.16.93.204:9200 [email protected]

Example

有机器A[10.16.31.56],B[10.16.93.204]。现想A通过ssh免密码登录到B

  • 在A机下生成公钥/私钥对 ssh-keygen -t rsa -P ''

  • 把A机下的id_rsa.pub复制到B机下scp ~/.ssh/id_rsa.pub [email protected]:/root/

  • B机把从A机复制的id_rsa.pub添加到.ssh/authorzied_keys文件里cat id_rsa.pub >> .ssh/authorized_keys

  • 把B机的authorized_keys文件夹加上600权限chmod 600 .ssh/authorized_keys

  • 实现免密码登录验证ssh [email protected]

sshtunnel

  • 使用方法go get -u github.com/farmerx/sshtunnel

  • 根据你的需要编译成不同平台下的程序

GO_ENABLED=0 GOOS=windows GOARCH=amd64  go build -o sshtunnel.exe github.com/sshtunnel
GO_ENABLED=0 GOOS=windows GOARCH=386  go build -o gosshtunnel.exe github.com/sshtunnel
GO_ENABLED=0 GOOS=linux GOARCH=amd64  go build -o sshtunnel github.com/sshtunnel
GO_ENABLED=0 GOOS=linux GOARCH=386  go build -o sshtunnel github.com/sshtunnel
  • 获取目标目录器的ssh rsa公钥到本地,把路径填写到SSHTunnel.conf中, 并在里面配置你要映射端口的目标服务器用户名、ssh端口、要监听的端口,和你要映射到本地那个端口,如下:
{
    "Username": "root", 
    "PublicKeyPath": "/Users/farmerx/.ssh/id_rsa", 
    "ServerAddrString": "10.16.93.204:22", 
    "RemoteAddrString": "10.16.93.204:9200"
    "LocalAddrString": "127.0.0.1:3690", 
}

sshtunnel's People

Contributors

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