如何在 Windows 10 上保持 SSH 连接活动? [英] How do I keep SSH connection alive on Windows 10?

查看:143
本文介绍了如何在 Windows 10 上保持 SSH 连接活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 10 上添加了 OpenSSH 客户端(测试版) 功能,所以我可以通过运行来调用它

I've added the OpenSSH client (Beta) feature on Windows 10 so I can call it by running

ssh

在命令行上.

但是,终端窗口(以及连接)在不活动时间过长时会冻结.我知道我会在 Linux 上通过编辑 ~/.ssh/config 文件来解决这个问题.Windows 上有类似的吗?

However the terminal windows (and thus the connection) freezes when inactive for too long. I know I would solve this on Linux by editing the ~/.ssh/config file. Is there an equivalent on Windows?

推荐答案

您可以在客户端通过设置选项 ServerAliveInterval 和 ServerAliveCountMax 来解决这个问题(60 和 30 将每分钟发送一个 keep-alive 数据包并仍然保持连接如果您的网络中断长达 30 分钟).

You can solve this on the client side by setting the options ServerAliveInterval and ServerAliveCountMax (60 and 30 will send a keep-alive packet every minute and still keep the connection if your network falls for up to 30 minutes).

Windows OpenSSH 客户端在查找 ssh_config 文件时遇到一些问题(它似乎对 Windows 系统中的主"目录有疑问),因此您可能必须使用 -F 显式提供配置文件路径:

The Windows OpenSSH client has some issues finding the ssh_config file (it appears to have doubts about what the "home" directory is in a Windows System), so you may have to explicitly provide the config file path with -F:

ssh -F C:\wherever\ssh_config user@host

在服务器端,您可以编辑/etc/ssh/sshd_config,编辑/添加类似的 ClientAliveInterval 和 ClientAliveMaxCount 选项并重新启动 sshd 服务.

On the server side you can edit /etc/ssh/sshd_config, edit/add the similar ClientAliveInterval and ClientAliveMaxCount options and restart the sshd service.

这篇关于如何在 Windows 10 上保持 SSH 连接活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆