暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Ngrok内网穿透

我不说你不造 2020-04-28
554

Ngrok-server安装

  • 环境:Ubuntu

安装Git

  1. sudo apt-get update

  2. sudo apt-get install git

复制

安装GO

  1. sudo apt-get install golang-go

复制

编译生成ngrok服务器程序

  1. export GOROOT=/usr/local/go/

  2. export GOPATH=/usr/local/go/bin/

  3. cd /usr/local/ngrok/

复制
  1. openssl genrsa -out rootCA.key 2048

  2. openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=ngrok.xxxx.cn" -days 5000 -out rootCA.pem

  3. openssl genrsa -out device.key 2048

  4. openssl req -new -key device.key -subj "/CN=ngrok.xxxx.cn" -out device.csr

  5. openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000

复制
  1. cp rootCA.pem assets/client/tls/ngrokroot.crt

  2. cp device.crt assets/server/tls/snakeoil.crt

  3. cp device.key assets/server/tls/snakeoil.key

复制
  1. make release-server

复制
  • 报错

  1. bin/go-bindata -nomemcopy -pkg=assets -tags=release \

  2. -debug=false \

  3. -o=src/ngrok/client/assets/assets_release.go \

  4. assets/client/...

  5. bin/go-bindata -nomemcopy -pkg=assets -tags=release \

  6. -debug=false \

  7. -o=src/ngrok/server/assets/assets_release.go \

  8. assets/server/...

  9. go get -tags 'release' -d -v ngrok/...

  10. import "container/list": import path doesn't contain a hostname

  11. package container/list: unrecognized import path "container/list"

  12. import "encoding/gob": import path doesn't contain a hostname

  13. package encoding/gob: unrecognized import path "encoding/gob"

  14. import "fmt": import path doesn't contain a slash

  15. package fmt: unrecognized import path "fmt"

  16. import "io": import path doesn't contain a slash

  17. package io: unrecognized import path "io"

  18. import "os": import path doesn't contain a slash

  19. package os: unrecognized import path "os"

  20. import "runtime": import path doesn't contain a slash

  21. package runtime: unrecognized import path "runtime"

  22. import "sync": import path doesn't contain a slash

  23. package sync: unrecognized import path "sync"

  24. import "time": import path doesn't contain a slash

  25. package time: unrecognized import path "time"

  26. import "bufio": import path doesn't contain a slash

  27. package bufio: unrecognized import path "bufio"

  28. import "bytes": import path doesn't contain a slash

  29. package bytes: unrecognized import path "bytes"

  30. import "compress/bzip2": import path doesn't contain a hostname

  31. package compress/bzip2: unrecognized import path "compress/bzip2"

  32. import "compress/flate": import path doesn't contain a hostname

  33. package compress/flate: unrecognized import path "compress/flate"

  34. import "compress/gzip": import path doesn't contain a hostname

  35. package compress/gzip: unrecognized import path "compress/gzip"

  36. import "context": import path doesn't contain a slash

  37. package context: unrecognized import path "context"

  38. import "crypto": import path doesn't contain a slash

  39. package crypto: unrecognized import path "crypto"

  40. import "crypto/rand": import path doesn't contain a hostname

  41. package crypto/rand: unrecognized import path "crypto/rand"

  42. import "crypto/rsa": import path doesn't contain a hostname

  43. package crypto/rsa: unrecognized import path "crypto/rsa"

  44. import "crypto/sha1": import path doesn't contain a hostname

  45. package crypto/sha1: unrecognized import path "crypto/sha1"

  46. import "crypto/sha256": import path doesn't contain a hostname

  47. package crypto/sha256: unrecognized import path "crypto/sha256"

  48. import "crypto/sha512": import path doesn't contain a hostname

  49. package crypto/sha512: unrecognized import path "crypto/sha512"

  50. import "crypto/tls": import path doesn't contain a hostname

  51. package crypto/tls: unrecognized import path "crypto/tls"

  52. import "crypto/x509": import path doesn't contain a hostname

  53. package crypto/x509: unrecognized import path "crypto/x509"

  54. import "encoding/base64": import path doesn't contain a hostname

  55. package encoding/base64: unrecognized import path "encoding/base64"

  56. import "encoding/binary": import path doesn't contain a hostname

  57. package encoding/binary: unrecognized import path "encoding/binary"

  58. import "encoding/hex": import path doesn't contain a hostname

  59. package encoding/hex: unrecognized import path "encoding/hex"

  60. import "encoding/json": import path doesn't contain a hostname

  61. package encoding/json: unrecognized import path "encoding/json"

  62. import "encoding/pem": import path doesn't contain a hostname

  63. package encoding/pem: unrecognized import path "encoding/pem"

  64. import "encoding/xml": import path doesn't contain a hostname

  65. package encoding/xml: unrecognized import path "encoding/xml"

  66. import "errors": import path doesn't contain a slash

  67. package errors: unrecognized import path "errors"

  68. import "flag": import path doesn't contain a slash

  69. package flag: unrecognized import path "flag"

  70. import "io/ioutil": import path doesn't contain a hostname

  71. package io/ioutil: unrecognized import path "io/ioutil"

  72. import "net": import path doesn't contain a slash

  73. package net: unrecognized import path "net"

  74. import "strconv": import path doesn't contain a slash

  75. package strconv: unrecognized import path "strconv"

  76. import "strings": import path doesn't contain a slash

  77. package strings: unrecognized import path "strings"

  78. import "math/rand": import path doesn't contain a hostname

  79. package math/rand: unrecognized import path "math/rand"

  80. import "net/http": import path doesn't contain a hostname

  81. package net/http: unrecognized import path "net/http"

  82. import "net/http/httptrace": import path doesn't contain a hostname

  83. package net/http/httptrace: unrecognized import path "net/http/httptrace"

  84. import "net/url": import path doesn't contain a hostname

  85. package net/url: unrecognized import path "net/url"

  86. import "unicode/utf8": import path doesn't contain a hostname

  87. package unicode/utf8: unrecognized import path "unicode/utf8"

  88. import "unsafe": import path doesn't contain a slash

  89. package unsafe: unrecognized import path "unsafe"

  90. import "path/filepath": import path doesn't contain a hostname

  91. package path/filepath: unrecognized import path "path/filepath"

  92. import "os/exec": import path doesn't contain a hostname

  93. package os/exec: unrecognized import path "os/exec"

  94. import "regexp": import path doesn't contain a slash

  95. package regexp: unrecognized import path "regexp"

  96. import "os/signal": import path doesn't contain a hostname

  97. package os/signal: unrecognized import path "os/signal"

  98. import "syscall": import path doesn't contain a slash

  99. package syscall: unrecognized import path "syscall"

  100. import "log": import path doesn't contain a slash

  101. package log: unrecognized import path "log"

  102. import "log/syslog": import path doesn't contain a hostname

  103. package log/syslog: unrecognized import path "log/syslog"

  104. import "math": import path doesn't contain a slash

  105. package math: unrecognized import path "math"

  106. import "reflect": import path doesn't contain a slash

  107. package reflect: unrecognized import path "reflect"

  108. import "runtime/debug": import path doesn't contain a hostname

  109. package runtime/debug: unrecognized import path "runtime/debug"

  110. import "runtime/pprof": import path doesn't contain a hostname

  111. package runtime/pprof: unrecognized import path "runtime/pprof"

  112. import "sort": import path doesn't contain a slash

  113. package sort: unrecognized import path "sort"

  114. import "sync/atomic": import path doesn't contain a hostname

  115. package sync/atomic: unrecognized import path "sync/atomic"

  116. import "unicode": import path doesn't contain a slash

  117. package unicode: unrecognized import path "unicode"

  118. import "html/template": import path doesn't contain a hostname

  119. package html/template: unrecognized import path "html/template"

  120. import "net/http/httputil": import path doesn't contain a hostname

  121. package net/http/httputil: unrecognized import path "net/http/httputil"

  122. import "path": import path doesn't contain a slash

  123. package path: unrecognized import path "path"

  124. import "os/user": import path doesn't contain a hostname

  125. package os/user: unrecognized import path "os/user"

  126. make: *** [deps] Error 1

复制

这是go语言版本过低,升级go语言

  1. sudo apt-get purge golang-go

  2. apt-get install golang-1.10

  3. ln -s /usr/local/go/bin/go /usr/bin/go

复制

编译客户端

  1. GOOS=windows #系统

  2. GOARCH=amd64 #64位系统

  3. GOARCH=386 #32位系统

  4. GOOS=windows GOARCH=amd64 make release-client

复制

启动ngrok服务

  1. /usr/local/ngrok/bin/ngrokd -tlsKey="/usr/local/ngrok/assets/server/tls/snakeoil.key" -tlsCrt="/usr/local/ngrok/assets/server/tls/snakeoil.crt" -domain="ngrok.xxxx.cn" -httpAddr=":8080" > log.out &

复制
  • 防火墙打开端口

  1. ufw allow 8081

  2. ufw allow 4443

复制

配置客户端

  • 新建ngrok.cfg文件

  1. server_addr: "ngrok.xxxx.cn:4443"

  2. trust_host_root_certs: false

  3. tunnels:

  4. http:

  5. proto:

  6. http: "127.0.0.1:80"

  7. subdomain: sub

  8. ssh:

  9. remote_port: 8082

  10. proto:

  11. tcp: "127.0.0.1:3389"

复制
  • 新建start.bat文件

  1. @echo on

  2. cd %cd%

  3. ngrok -config=ngrok.cfg -log=ngrok.log start ssh http

复制

双击运行start.bat
开启内网穿透。


文章转载自我不说你不造,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论