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

SSH usually hangs before password prompt

· 52CE 我爱测

I am trying to SSH onto a linux server: ssh -X -l <username> <address> When I am connected through my home WiFi router (which is very fast), this command might hang indefinitely. (For others, such as when I use my phone's mobile …

问题原文

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

I am trying to SSH onto a linux server:

ssh -X -l <username> <address>

When I am connected through my home WiFi router (which is very fast), this command might hang indefinitely. (For others, such as when I use my phone's mobile data, it connects immediately 100% of the time). If I repeat the ssh command enough times (in the order of 100 times), by executing the command and then immediately hitting control c if it doesn't prompt, I can usually get it to respond, although this is not failsafe. When it finally works, the prompt is immediate, and the terminal is very responsive. If I let the ssh command hang waiting for the password prompt, it sometimes will prompt my password after a few seconds to a few minutes, but it also might hang for an hour.

I am not an administrator on the server I am trying to connect to, thus I cannot enable UseDNS no on the server. Is this definitely the problem? Why does it treat my mobile data differently from my home WiFi?

Update

Here is the sanitized output when run using -vvv

debug1: Reading configuration data /Users/userName/.ssh/config
debug2: checking match for 'exec "/usr/local/bin/sft resolve -q  %h"' host address originally address
debug1: Executing command: '/usr/local/bin/sft resolve -q  address'
debug3: command returned status 126
debug3: /Users/userName/.ssh/config line 2: not matched 'exec "/usr/local/bin/sft resolve -q  address"' 
debug2: match not found
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to address port 22.

Here it hangs.

已采纳解答

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

The easiest way to get around this is to use the server's ip address rather than relying on DNS to find it for you. So:

ssh -Xl <username> 123.456.789.0

Seems kind of trivial but if you're an inexperienced networker then you might not have thought of this (as I hadn't)

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

资料来源与适用范围

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

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

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