1. 将远程跳板机内网服务的mysql 隧道给本机用
ssh jump@111.111.111.111 -L 3307:192.168.14.253:3308
2. 将远程跳板机内网服务的mysql 隧道给本指定IP上)
(容器内部仿问外部数据库情况)
ssh jump@111.111.111.111 -L 172.23.0.1:3307:192.168.14.253:3308
注:仅能使用172.23.0.1才能连通3307端口
2. 将远程跳板机内网服务的mysql 隧道给本机任意IP上)
(容器内部仿问外部数据库情况)
ssh jump@111.111.111.111 -L 0.0.0.0:3307:192.168.14.253:3308
3. 将本机端口提供给远程使用(后台运行)
ssh -R 3307:127.0.0.1:3307 root@192.168.147.2 -NTf
4. 将本机能仿问的网络端口提供给远程使用(后台运行)
ssh -R 3307:www.baidu.com:80 root@192.168.147.2 -NTf
5. 使用expect做ssh+隧道命令
#!/usr/bin/expect
set timeout 30
set host "111.111.111.111"
set username "xxxx"
set password "xxxx"
spawn ssh $username@$host -L 3307:192.168.14.253:3308
expect "*password*" {send "$password\r"}
interact
6. 自定义ssh隧道工具,完成一键登陆
6.1 编写支持参数的sh脚本:m-ssh.sh
#!/usr/bin/expect
if {$argc < 3} {
puts "Usage:cmd <host> <username> <password>"
exit 1
}
set timeout 30
set host [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set lpath [lindex $argv 3]
if {$lpath != ""} {
spawn ssh $username@$host -L $lpath
expect "*password*" {send "$password\r"}
interact
}
spawn ssh $username@$host
expect "*password*" {send "$password\r"}
interact
6.2. 将m-sh.sh
授可执行权限
chmod u+x m-ssh
6.3 使用
m-ssh 111.111.111.111 22 jump jump 3308:192.168.2.22:3306