ssh隧道(跳板机)
作者:互联网
通过ssh跳板机,连接远端mysql
本机:192.168.0.59
跳板机:121.212.2.22
mysql服务器:192.168.1.23(公网服务器的内网网卡IP,跟跳板机内网相连)
[root@localhost ~]# ssh -p 62222 -N -f -L 61001:192.168.1.231:3306 yuejianyuan@121.212.2.22
说明:
-p: yuejianyuan@121.212.2.22的ssh端口
-N: 不执行远程命令 (该参数在只打开转发端口时很有用)
-f: 一旦SSH完成认证并建立port forwarding,则转入后台运行
-L: 地址
最后接跳板机
[root@localhost ~]# mysql -h 127.0.0.1 -uusername -p -P61001
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 40548
Server version: 5.6.34-log MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
---------------end
标签:隧道,MySQL,192.168,ssh,mysql,2.22,跳板 来源: https://blog.csdn.net/oToyix/article/details/116055719