Files
tunnel/README.md
2023-03-25 09:06:37 +08:00

45 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# db_tunnel
结合TELEPORT堡垒机使用的DB SSH数据库隧道工具
数据库配置文件请放到/etc或者与bin文件同一路径
# build
git clone https://git.aixiao.me/aixiao/db_tunnel.git
cd db_tunnel
bash bash build.sh可能会提示安装包
# test
root@NIUYULING:/mnt/c/Users/niuyuling/Desktop/tunnel# ./bin/tunnel -h
flag needs an argument: -h
Usage of ./bin/tunnel:
-c int
建立隧道最大次数与DB服务器断开 (default 999)
-d run in daemon
-f run forever
-h string
DB服务器SSH IP地址
-l string
本地监听端口(或者堡垒机监听端口)
-p string
DB服务器SSH PORT
-r string
DB服务器端口如: 3306、1521 ...
-u string
DB服务器SSH USER用户
root@NIUYULING:/mnt/c/Users/niuyuling/Desktop/tunnel#
root@NIUYULING:/mnt/c/Users/niuyuling/Desktop/tunnel/bin# ./tunnel -d -f -c 500 -h 47.108.253.59 -p 22 -u app -r 3306 -l 3306
[*] Daemon running in PID: 28640 PPID: 24
root@NIUYULING:/mnt/c/Users/niuyuling/Desktop/tunnel/bin# [*] Forever running in PID: 28645 PPID: 1
[*] Service running in PID: 28649 PPID: 28645
数据库连接成功
47.108.253.59 22 app hyj4Sxq1UQUJ0RF95MQGf1oNUSdZ/rlIYNXu9DPSCLt3sNsXCpKmRtm85tFCRPN
0Hv5m&uRwYKFZdu
2023/03/15 12:15:55.161984 PID: 28649 PPID: 28645 本地端口: 3306 当前连接数:1
2023/03/15 12:15:55.162630 listening for new connections...
root@NIUYULING:/mnt/c/Users/niuyuling/Desktop/tunnel/bin#