ssh转发

ali-confluent-2

/user/hive/warehouse
/user/hive/warehouse/db_test1.db

yum install expect -y
cd /root
cd /root/.ssh/
vim config
Host oride-ops
HostName 152.32.140.150
Port 22
User root
IdentityFile ~/.ssh/uc2

vim uc2
私钥

mkdir .nat_rules/oride -p
vim oride-ops-mysql-13311
#!/bin/bash
L_PORT="13311"
R_HOST="10.52.80.112"
R_PRI_PORT="13305"
MON_PORT="0"
ALIAS="oride-ops"

VAR=$(expect -c "
spawn /usr/bin/autossh -M $MON_PORT -4 -C -L 0.0.0.0:$L_PORT:$R_HOST:$R_PRI_PORT -N $ALIAS
match_max 100000
expect "$?assphrase*"
send -- "$PASS "
send -- " "
expect eof
")
echo "======================="
echo "$VAR"
~

原文地址:https://www.cnblogs.com/hongfeng2019/p/12018867.html