如何打开SSH 22端口?

如何打开SSH 22端口?

我已在嵌入式系统上安装了 ssh 实用程序,但无法连接到它。我可以从设备 ssh 到网络上的另一台计算机,但反之则不行。

设备中唯一打开的端口是 21 号端口:

userk@dopamine:~$ nmap 160.80.97.X

Starting Nmap 6.40 ( http://nmap.org ) at 2015-02-09 20:49 CET
Nmap scan report for 160.80.97.X
Host is up (0.0092s latency).
Not shown: 999 closed ports
PORT   STATE SERVICE
21/tcp open  ftp

当我尝试连接到它时,出现连接被拒绝错误。我尝试过另一个端口,但没有任何改变。配置文件/etc/ssh/sshd_config如下

#Port 22
Port 223
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 1h
ServerKeyBits 1024

# Ciphers and keying
#RekeyLimit default none

# Logging
# obsoletes QuietMode and FascistLogging
SyslogFacility AUTH
LogLevel INFO

# Authentication:

LoginGraceTime 2m
PermitRootLogin yes
StrictModes yes
MaxAuthTries 6
#MaxSessions 10

RSAAuthentication yes
PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile  .ssh/authorized_keys

我没有 iptables,无法安装。如何使用 ssh 连接到设备?

解决方案

生成的密钥有问题。将它们移动到 /tmp 文件夹

mv /etc/ssh/ssh_host_* /tmp

并重新生成密钥

/etc/init.d/S50sshd restart OR /etc/init.d/sshd restart

或者

ssh-keygen -A

感谢 Braatchley、Abrixas2 和 0xC0000022L。

答案1

#Port 22
Port 223

这不是 22 被注释掉而 223 是活跃的吗?你试过223了吗?

相关内容