如何修复 OpenWRT 故障安全模式 SSH 端口 22: Connection refused

问题:

你正在尝试使用 SSH 通过 ssh 192.168.1.1 连接到故障安全模式下的 OpenWRT 路由器,但你看到此错误消息:

output.txt
ssh: connect to host 192.168.1.1 port 22: Connection refused

解决方案

首先,检查你是否有正确的 IP 配置:

Ping 192.168.1.1 以验证你的 IP 配置:

ping.sh
ping 192.168.1.1

示例输出:

ping_output.txt
uli@uli-computer:~$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=63 time=1.20 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=63 time=1.35 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=63 time=1.14 ms

然后,尝试再次使用 SSH 连接:

ssh_connect.sh

如果你仍然得到

output.txt
ssh: connect to host 192.168.1.1 port 22: Connection refused

你运行的是旧版 OpenWRT。故障安全模式下的 SSH 仅从 OpenWRT 15.05 开始支持。对于旧版本,使用 telnet 连接:

telnet.sh
telnet 192.168.1.1

你应该看到 root shell:

telnet_output.txt
elnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

 === IMPORTANT ============================
    Use 'passwd' to set your login password
    this will disable telnet and enable SSH
 ------------------------------------------


BusyBox v1.19.4 (2013-03-14 11:28:31 UTC) built-in shell (ash)
Enter 'help' for a list of built-in commands.

    _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
                    |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 ATTITUDE ADJUSTMENT (12.09, r36088)
 -----------------------------------------------------
    * 1/4 oz Vodka      Pour all ingredients into mixing
    * 1/4 oz Gin        tin with ice, strain into glass.
    * 1/4 oz Amaretto
    * 1/4 oz Triple sec
    * 1/4 oz Peach schnapps
    * 1/4 oz Sour mix
    * 1 splash Cranberry juice
 -----------------------------------------------------
root@(none):/#

Check out similar posts by category: Networking