Bug 2001221

Summary: sshd fails to start during boot while configured to bind with specific IP Address using "ListenAddress <IPADDRESS>"
Product: Red Hat Enterprise Linux 8 Reporter: Nandhakumar Madheshwaran <nmadhesh>
Component: opensshAssignee: Dmitry Belyavskiy <dbelyavs>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: low Docs Contact:
Priority: unspecified    
Version: 8.4CC: jjelen
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-09-04 16:51:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nandhakumar Madheshwaran 2021-09-04 13:13:09 UTC
Description of problem:
~~~~~~~~~~~~~~~~~~~~~~~

sshd.service fails to start during boot if configured to bind with a specific IP Address using "ListenAddress <IPADDRESS>" directive.

Sep 04 00:18:59 nmadhesh_rhel8 sshd[800]: error: Bind to port 22 on 192.168.0.XXX failed: Cannot assign requested address.
Sep 04 00:18:59 nmadhesh_rhel8 sshd[800]: fatal: Cannot bind any address.

It looks like the sshd is starting before the network is completely online.

However, the service sshd is started later 42seconds while it was reattempted to start.


Version-Release and involved Components (if applicable):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OS Distro 	: Red Hat Enterprise Linux release 8.4 (Ootpa)
Arch		: x86_64
openssh-server-8.0p1-6.el8_4.2.x86_64
NetworkManager-1.30.0-10.el8_4.x86_64



Steps to Reproduce:
~~~~~~~~~~~~~~~~~~~

1. Configure the sshd to listen to a specific IP Address.

$ grep ListenAddress /etc/ssh/sshd_config 
ListenAddress 192.168.0.XXX


2. Reboot the system and see the sshd service will fail with the following error.


Sep 04 17:53:17 nmadhesh_rhel8 sshd[793]: error: Bind to port 22 on 192.168.0.XXX failed: Cannot assign requested address.
Sep 04 17:53:17 nmadhesh_rhel8 sshd[793]: fatal: Cannot bind any address.
Sep 04 17:53:17 nmadhesh_rhel8 systemd[1]: sshd.service: Main process exited, code=exited, status=255/n/a
Sep 04 17:53:17 nmadhesh_rhel8 systemd[1]: sshd.service: Failed with result 'exit-code'.
Sep 04 17:53:17 nmadhesh_rhel8 systemd[1]: Failed to start OpenSSH server daemon.


3. If we wait for some time(42Seconds), then sshd service will be attempted to be restarted by systemd. This makes the boot time longer than usual.

Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: sshd.service: Service RestartSec=42s expired, scheduling restart.
Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: sshd.service: Scheduled restart job, restart counter is at 1.
Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: Stopped OpenSSH server daemon.
Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: Stopped target sshd-keygen.target.
Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: Stopping sshd-keygen.target.
Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: Reached target sshd-keygen.target.
Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: Starting OpenSSH server daemon...
Sep 04 17:53:59 nmadhesh_rhel8 sshd[1314]: Server listening on 192.168.0.XXX port 22.
Sep 04 17:53:59 nmadhesh_rhel8 systemd[1]: Started OpenSSH server daemon.

Actual results:
~~~~~~~~~~~~~~~
sshd service fails to start during boot before the Network/IP Address is online.


Expected results:
~~~~~~~~~~~~~~~~~
sshd service should start without any issues after the Network/IP Address is online during system boot.


Additional info:
~~~~~~~~~~~~~~~~

Adding 'After=network-online.target' as a dependency under the sshd.service unit file helps to start sshd without fail.

But any future updates of openssh-server will override these changes. Need a permanent solution.

Comment 1 Dmitry Belyavskiy 2021-09-04 16:51:03 UTC
Looks like a duplicate of bz#1936538 to me

*** This bug has been marked as a duplicate of bug 1936538 ***