4

My experience with Linux is limited and as part of a project, I ordered a Linux dedicated server. This is an unmanaged server with OpenSuSE 13.2. When I try to ssh into the server, I get a connection refused message

ssh: connect to host xxx.xxx... port 22: Connection refused

I think their default image does not comes with ssh enabled on startup but I may be wrong. They provide a rescue system which is a Linux system installed and loaded from ram for troubleshooting. When I load this, I can connect to the system via SSH. I can mount the hdd and make changes.

I'd like to know how to check and/or whatever configuration changes that need to be done to enable ssh on startup for OpenSuSE 13.2 from within a recovery system. I can provide any configuration file contents if required. I'm basically from a Windows background and hence if you can provide verbose steps, it will be helpful.

As part of my research, I checked init.d file, there was no sshd file in there, ssh is installed I guess as there exists files in /etc/ssh like `/etc/ssh/sshd_config.

kasperd
  • 29,894
  • 16
  • 72
  • 122
Mat J
  • 141
  • 1
  • 1
  • 4
  • 1
    My question as specified by the title is not about the connection refused error. – Mat J Mar 29 '16 at 09:27
  • This question is **not** asking what causes a connection refused message. It asks how to check which services are enabled on an OpenSuSE system, and how to change it. As such it should not have been closed as a duplicate. – kasperd Apr 17 '16 at 09:18

2 Answers2

10

1. Verify installation

Run which sshd to get the path it is called from. If you don't get /usr/sbin/sshd in response, it is most likely not installed.

2. Installing sshd

Run zypper in openssh to install the application.

3. Check firewall

Run the command cat /etc/sysconfig/SuSEfirewall2 | grep sshd.

You need to see FW_CONFIGURATIONS_EXT="sshd" - This means the firewall allows incoming traffic on port 22.

If you do not find it, you may add it using a text editor like this:

vi /etc/sysconfig/SuSEfirewall2 and locate the line where it says FW_CONFIGURATIONS_EXT="" and change it to FW_CONFIGURATIONS_EXT="sshd"

4. Check the service is running

systemctl status sshd | grep Active - If you get Active: inactive (dead) you need to start it with systemctl start sshd.

Run the command again systemctl status sshd | grep Active and you should now see Active: active (running) since ...

5. Enable SSH on startup

systemctl enable sshd

hesonline
  • 101
  • 1
  • 3
  • You are reading only part of the question. I sincerely appreciate your efforts, but the problem is, system while in running condition cannot be accessed because its a remote machine and only mode of access, the `ssh` is not running, but I can access the hard disk, I needed to get configuration changes to be done on the files in this HDD, from an external OS, so that next time OS is booted from this hard disk, `ssh` will be running. My actual requirement is no more active but if someone can answer, it might help someone else. – Mat J Jul 06 '16 at 10:31
  • How were you accessing the system? If you were able to determine files exist in `/etc/ssh` you must have access of some kind. Was this through a cloud provider? Were you running it on a ESXi server on your own network? How did you access the disk through an external OS (I assume you mean from another host). Too bad I got to this question so late, because now I really want to solve it. – hesonline Jul 06 '16 at 15:22
  • It is through a recovery system, another linux system booted up in memory much like a live cd. It is an provided by the hosting provider. – Mat J Jul 06 '16 at 17:55
5

OpenSUSE as of Leap 15, and Tumbleweed got rid of the old firewall in favor of as used on Fedora. That changes how you add the SSH config:

firewall-cmd --add-service=ssh --zone=external --permanent

--add-service=ssh Since SSH is one of the predefined services, you can use it as a service. The alternate is --add-port=22.

--zone=external Updates the external zone. Zones are assigned to interfaces.

--permanent Persists this change across reboots.

To verfiy this is done, the XML files in /etc/firewalld/zones can be examined.

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>External</short>
  <description>For use on external networks.</description>
  <interface name="eth0"/>
  <service name="ssh"/>
  <masquerade/>
</zone>
sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
  • Thank you for the answer, but I think I articulated the question wrong. Though not relevant anymore, the question basically was, I have remote access to a HDD with opensuse image (access is through a different linux OS), this HDD can be booted, but the opensuse on it don't have ssh enabled, so through the remote access to the HDD through a different linux OS, what changes to be made on the files in HDD itself, so that next time it is booted, SSH access is available on the opensuse system. So I cannot call commands inside opensuse, just edit files. – Mat J Feb 16 '19 at 11:36