更换库

This commit is contained in:
2023-03-25 09:06:37 +08:00
parent 4878a9e21f
commit 1f251c8b1c
16 changed files with 677 additions and 411 deletions

View File

@@ -1,39 +1,44 @@
# 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/db_tunnel# ./db_tunnel -h
flag needs an argument: -h
Usage of ./db_tunnel:
-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/db_tunnel#
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/db_tunnel/bin# ./db_tunnel -d -f -h 39.104.27.21 -l 3308 -r 3306 -p 22 -u app
[*] Daemon running in PID: 12918 PPID: 67
root@NIUYULING:/mnt/c/Users/niuyuling/Desktop/db_tunnel/bin# [*] Forever running in PID: 12922 PPID: 1
[*] Service running in PID: 12927 PPID: 12922
39.104.27.21 22 app 3306 3308
39.104.27.21 app 22
数据库连接成功
39.104.27.21 22 app 6+sNDSN4QL7VCLSr+Vt/fNSAX1XsTUwf6fYRTf3pGS8rYBn8Ik
I9EKbb
设置SSH配置服务器:39.104.27.21:22; 用户/密码: app/I9EKbbH; 远程:0.0.0.0:3306; 本地:0.0.0.0:3308
root@NIUYULING:/mnt/c/Users/niuyuling/Desktop/db_tunnel/bin#
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#