内网穿透ngrok编译和安装

1、安装git
yum install -y git
2、安装go环境
yum install -y epel-release
yum install -y golang
go version
3、clone 代码
git clone https://github.com/inconshreveable/ngrok.git ngrok
cd ngrok
export GOPATH="$(pwd)"
go env
4、生成证书
export NGROK_DOMAIN="ngrok.example.com" #换成你的域名(绑定外网IP的域名或者本地Host解析域名)
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem
openssl genrsa -out server.key 2048
openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 5000
cp rootCA.pem assets/client/tls/ngrokroot.crt -i
cp server.crt assets/server/tls/snakeoil.crt -i
cp server.key assets/server/tls/snakeoil.key -i
5、编译windwos版
5.1 Windows版
服务端x86:GOOS=windows GOARCH=386 make release-server
客户端x86:GOOS=windows GOARCH=386 make release-client
服务端x64:GOOS=windows GOARCH=amd64 make release-server
客户端x64:GOOS=windows GOARCH=amd64 make release-client release-server
5.2 Linux版
服务端x86:GOOS=linux GOARCH=386 make release-server
客户端x86:GOOS=linux GOARCH=386 make release-client
服务端x64:GOOS=linux GOARCH=amd64 make release-server
客户端x64:GOOS=linux GOARCH=amd64 make release-client 
5.3 MacOS版
服务端x86:GOOS=darwin GOARCH=386 make release-server
客户端x86:GOOS=darwin GOARCH=386 make release-client
服务端x64:GOOS=darwin GOARCH=amd64 make release-server
客户端x64:GOOS=darwin GOARCH=amd64 make release-client 
6、Linux启动

设置hosts:

echo "192.168.94.14 ngrok.example.com" >> /etc/hosts

服务端:

cd /root/ngrok/bin
./ngrokd -domain="ngrok.example.com" -httpAddr=":1222" -httpsAddr=":443"

客户端:
cd /root/ngrok/bin
vim ngrok.cfg

server_addr: ngrok.example.com:4443
trust_host_root_certs: false
tunnels:
    http:
        proto:
            http: 80
        subdomain: pi
    ssh:
        remote_port: 12222
        proto:
            tcp: 22
    mstsc:
        remote_port: 13389
        proto:
            tcp: 3389

启动客户端:

./ngrok -config=ngrok.cfg start ssh
7、Windows启动

服务端:

ngrokd.exe -domain="ngrok.example.com" -httpAddr=":1222" -httpsAddr=":443" -tunnelAddr=":4443"

客户端:

ngrok.exe -config=ngrok.cfg start mstsc
8、客户端修改HOSTS

Windows

echo 192.168.1.102 ngrok.example.com >> C:\Windows\System32\drivers\etc\hosts

Linux

echo 192.168.1.102 ngrok.example.com >> /etc/hosts
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值