OpenSUSE15.6 ; Firewall , SSH、NTP Server

1. Setting up remote connection by SSH

SSH is a service for connecting remotely to a server and is basically running immediately after the OS is installed, but the default settings are somewhat insecure.
Here we will configure the default settings to increase the security of ssh connections.

1.1 SSH service configuration file changes

Modify the configuration file to change the SSH service settings.
The SSH service configuration file is "/etc/ssh/sshd_config".

Restart SSH

If this is not done, the next time you reboot, you will not be able to connect remotely via SSH. Please allow SSH port 2244 in the following firewall settings.

2.How to set up a firewall (firewalld)

In openSUSE, the firewall is set to firewalld by default and is enabled during OS installation.

To briefly explain firewalld, when setting up a communication control policy, communication permission/blocking rules are applied to predefined zones, and the zones are assigned to each NIC (network adapter).

2.1 How to use the firewall-cmd command to control "firewalld".

1)About Zones
Nine zones are provided by default

zoneCommunication Permission ServiceDescription.
blockNone All external connections are blockedSetting cannot be changed Return "CIMP Pohibited" when blocked, return communication is also allowed when communicating from inside
dmzsshZones defined for dmz
dropNone All external communications are blockedCannot change settings Internal communication can be sent, but return communication from the outside is blocked, resulting in all communication not being possible.
externalsshZone defined for use in connection with external networks, such as routers with IP masquerade enabled.
homedhcpv6-client  ipp-client  mdns  samba-client  sshZones defined for use at home, etc.
internaldhcpv6-client  ipp-client  mdns  samba-client Zone defined for use in the internal network.
publicdhcpv6-client sshZones defined for use in public places.
trustedAllow all communicationSetting cannot be changed
workdhcpv6-client ipp-client sshZones defined for use in work areas such as the workplace.

2)Command to check the status and settings of firewalld

①Check firewalld operation status

If "firewalld" is running, "running" will be displayed; if it is not running, "not running" will be displayed.


※If stopped
Active: inactive (dead) is displayed, indicating that firewalld is stopped

Show default zone settings

In the above example, the "public" zone is the "default" setting and is assigned to the "eth0" NIC, and the services "dhcpv6-client" and "ssh" are allowed, etc.

Show the settings for the specified zone.

The following example shows how to display the settings for the "dmz" zone

About the "--permanent" option
In order to prevent the settings from being lost when the server is restarted or the "firewalld" service is restarted, the "--permanent" option must be used.
To prevent the settings from being lost when the server is restarted or the "firewalld" service is restarted, the "--permanent" option must be used to configure the settings. In this case, if the "--permanent" option is specified, the settings will not be reflected in "firewalld" as they are, so it is necessary to reflect the settings using "fiewall-cmd --reload".
As an example, to use the HTTP service permanently without being initialized even if the system is rebooted

Adding and removing services to and from a zone
To add an already defined service to a zone, use "-add-service" to specify the service
# firewall-cmd [--permanent] --zone=zone name --add-service=service name
If you want to permanently add services to a zone, you must configure it with the "--permanent" option.

Example configuration for temporarily adding a service

Example of adding a service permanently
Example of adding the "http" service to a "public" zone with the "--permanent" option

service deletion
Use "--remove-service" to remove a service configured for a zone
Remove the "http" service from the "public" zone as an example

Add or remove ports to a zone
To add communications not added as a service to a zone, specify the port number and protocol to be added

Adding a port by specifying a zone

Use "--add-port" to add a port to a zone
Configuration Example
Let's add a rule for port number "10022" and protocol "TCP" in the "public" zone

Deleting a port by specifying a zone

Use "--remove-port" to remove a port from a zone

Configuration Example
Delete the "10022/tcp" rule for the "public" zone added earlier

How to start and stop

Since firewalld is controlled by systemd, use the systemctl command to start and stop it.
Start firewalld

2.2  Allow modified SSH port 2244

3.Remote connection from Windows

Configuration in Windows

Start setting up a remote connection from Windows, using "Tera Term" as the terminal emulator.
Start Tera Term, cancel the startup screen, and then select "New Connection" from "File" in the Tera Term menu.

Enter the following information on the next screen.
Host : Server IP Address
TCP port : SSH port number changed above

After clicking "OK," click "Continue" on the security confirmation screen.

Enter the following information on the next screen.
User name : General Login Username
Passphrase : Password for the above user

If the information is correct, you should be able to log in successfully.

4. NTP Server Settings

Install Chrony and build an NTP server for time synchronization. Note that NTP uses 123/UDP.

4.1 Chrony Install

4.2 Chrony Settings

4.3 Open NTP port

If Firewalld is enabled, permission for NTP service is required. Note that NTP uses 123/UDP.

4.4 operation check

Copied title and URL