我使用跳转主机从 Windows 10 电脑上的 OracleLinux 8.4 VM(在 VirtualBox 上配置了 NatNetwork)运行脚本到远程主机。
我的电脑无法直接连接远程主机,连接VPN后需要经过跳转主机。
这是我的环境:
| 服务器 | 知识产权 |
|---|---|
| Windows PC 局域网: | 192.168.0.10 |
| Windows PC VPN: | 10.201.66.134 |
| OracleLinux 虚拟机: | 10.0.100.100 |
| 跳跃主机 | 90.xxx |
我在脚本中使用这些参数:
-o ProxyCommand="sshpass -p $SSHPASS ssh -vvv -W %h:%p ispjh"
-o PubkeyAuthentication=no
-o PreferredAuthentications=password
-o PasswordAuthentication=yes
-o ControlMaster=auto
-o ControlPersist=60s
-o UserKnownHostsFile=/dev/null
-o StrictHostKeyChecking=no
Run Code Online (Sandbox Code Playgroud)
这是我在虚拟机上的 ssh 配置: [root@VM ~]# cat ~/.ssh/config Host * TCPKeepAlive no ServerAliveInterval 300 ServerAliveCountMax 1296000
Host jumphost jumphost.mydonain.local
Hostname jumphost.mydonain.local
User user.name
ControlMaster auto
ControlPath /tmp/ssh-%r@%h:%p
DynamicForward 1083
Run Code Online (Sandbox Code Playgroud)
我在运行脚本之前(使用命令:)和之后创建了 …