大网数据广告活动
服务器运维问答

persistent SSH connection while connecting to VPN

· 52CE 我爱测

I have a Linux machine on the intranet which I can only access via SSH. This machine needs to connect to a VPN using OpenConnect; however when I do that, I get disconnected from the SSH session since the intranet's IP is no longe…

问题原文

原帖链接 · Samus_ · CC BY-SA 4.0

I have a Linux machine on the intranet which I can only access via SSH. This machine needs to connect to a VPN using OpenConnect; however when I do that, I get disconnected from the SSH session since the intranet's IP is no longer valid.

I can reconnect to it from within the VPN using the IP it got assigned, but that IP changes every time the VPN is connected. I don't have control over any of the networks, only this machine.

Is there a way to keep the SSH connection alive while connecting to the VPN?


openconnect requires a --script argument which takes a script to configure routing. Without it the connection succeeds, but no names are resolved and the intranet's IP remains valid.

I'm currently using Ubuntu's default /etc/vpnc/vpnc-script. I'm good with shell scripting but I know very little about networking. If I have to modify that, I'll need some reference about what or how to change it.

社区高分解答

原帖链接 · EEAA · CC BY-SA 3.0

is there a way to keep the SSH connection alive while connecting to the VPN?

No. That system's routing changes dramatically when you connect to the VPN, which breaks all established TCP sockets.

You should look into using a terminal multiplexer like screen or tmux in your ssh session - that way you can have a persistent shell that you can re-connect to.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-06-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0 / CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。