5

我正在尝试启用 ssh 连接到 suse linux。我正在运行 sshd 服务:

peeyush@linux-pohb:~/gccgo.work> systemctl status sshd.service
sshd.service - OpenSSH Daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
   Active: active (running) since Thu 2015-03-19 18:36:05 IST; 3h 50min ago
  Process: 5702 ExecStartPre=/usr/sbin/sshd-gen-keys-start (code=exited, status=0/SUCCESS)
 Main PID: 6035 (sshd)
   CGroup: /system.slice/sshd.service
           └─6035 /usr/sbin/sshd -D

Mar 19 18:36:01 linux-pohb sshd-gen-keys-start[5702]: Checking for missing se...
Mar 19 18:36:05 linux-pohb sshd-gen-keys-start[5702]: ssh-keygen: generating ...
Mar 19 18:36:06 linux-pohb sshd[6035]: Server listening on 0.0.0.0 port 22.
Mar 19 18:36:06 linux-pohb sshd[6035]: Server listening on :: port 22.
Hint: Some lines were ellipsized, use -l to show in full.

它正在监听 22 端口:

peeyush@linux-pohb:~/gccgo.work> netstat -an | grep :22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      
tcp        0      0 :::22                   :::*                    LISTEN 

但我无法连接到它。

[root@lep8a peeyush]# ssh root@192.168.122.19
ssh: connect to host 192.168.122.19 port 22: Connection timed out

在互联网上寻找解决方案让我头疼。没有任何工作。你们能帮帮我吗?

4

3 回答 3

17

检查您的防火墙是否接受端口 22 上的传入 TCP 连接:

# iptables -nL | grep 22

如果结果为空,则必须在防火墙中添加规则。

打开 Yast 和防火墙配置:

# yast firewall

转到“允许的服务”并添加“安全外壳服务器”。保存并退出 Yast 并尝试连接。

评论:如果您已完全禁用防火墙(不推荐),则此答案不适用。

于 2015-06-04T11:44:49.767 回答
7

运行此命令:

systemctl enable sshd.service

/etc/ssh/sshd_config然后在您的文件中进行必要的更改,并sshd通过以下方式开始:

systemctl start sshd.service
于 2015-09-08T06:31:21.183 回答
1

我在SUSE Linux Enterprise Server 15 x86-64中处理了同样的问题。在系统内我能够# ssh 127.0.0.1(因此 sshd 服务正常工作),但从其他节点我收到“超时”消息。

首先,我检查了防火墙规则(请参阅 xloto 的答案):

# iptables -nL | grep 22

导致返回空消息,所以我们需要设置一个额外的规则。

要为 SSH 的标准端口 22 设置防火墙规则,我遵循了另一个教程(因为我没有 GUI):

# firewall-cmd --permanent --add-service=ssh
# firewall-cmd --reload

它适用于我的情况,但我不确定这是否是最佳做法。

于 2018-10-05T11:42:09.990 回答