How to enable ssh on startup in opensuse
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
OpenSUSE as of Leap 15, and Tumbleweed got rid of the old firewall in favor of firewalld 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>