5

I am trying to enable ssh connection to suse linux. I have sshd service running:

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.

It is listening on port 22 fine:

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 

But I am not able to connect to it.

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

My head is aching with finding solutions on internet. Nothing is working. Could you guys please help me out?

Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116
Pensu
  • 3,263
  • 10
  • 46
  • 71
  • 2
    Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. Also see [Where do I post questions about Dev Ops?](http://meta.stackexchange.com/q/134306). – jww Mar 22 '16 at 00:08

3 Answers3

17

Check if your firewall accepts incoming TCP connections on port 22:

# iptables -nL | grep 22

If the result is empty, you have to add a rule in your firewall.

Open Yast and firewall configuration:

# yast firewall

Goto "Allowed Services" and add "Secure Shell Server". Save and quit Yast and try to connect.

Comment: If you have disabled your firewall completly (not recommended) this answer does not apply.

xloto
  • 460
  • 4
  • 8
7

Run this command:

systemctl enable sshd.service

Then make necessary changes in your /etc/ssh/sshd_config file, and start sshd via:

systemctl start sshd.service
Will
  • 24,082
  • 14
  • 97
  • 108
dddio
  • 79
  • 1
  • 2
  • 1
    sshd.service is already enabled as per the output in question. You should have provided info on "necessary" changes in the config file... – Marki555 Sep 08 '15 at 06:33
  • 1
    Other people find this answer by googling and this answer helps them. – Warren P Nov 18 '16 at 00:16
1

I was dealing with the same problem in SUSE Linux Enterprise Server 15 x86-64. Within the system I was able to # ssh 127.0.0.1 (so the sshd service was working correctly), but from other nodes I got a "Timed out" message.

First, I checked the firewall rules (see answer from xloto):

# iptables -nL | grep 22

Resulted in an empty return message, so we need to set an additional rule.

To set the the firewall rule for SSH's standard port 22, I followed another tutorial (as I do not have a GUI):

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

It worked for my case, but I'm not sure whether this is best practice.

Kiwi
  • 513
  • 5
  • 6