I'm running Arch Linux. After I reboot, the sshd.service fails to start due to the network not yet being up. I have to manually run:

sudo systemctl restart sshd

Once I do that, the sshd service starts without any errors and it operates correctly. How do I resolve this so that the systemd sshd.service will start automatically as it should?

Here are the logs:

May 06 15:47:23 server2 nm-dispatcher[471]: req:3 'connectivity-change': completed: no scripts
May 06 15:47:23 server2 nm-dispatcher[471]: req:3 'connectivity-change': new request (0 scripts)
May 06 15:47:23 server2 NetworkManager[440]: <info>  [1525636043.9284] manager: NetworkManager state is now CONNECTED_GLOBAL

May 06 15:47:22 server2 nm-dispatcher[471]: req:2 'up' [eth0]: completed: no scripts
May 06 15:47:22 server2 nm-dispatcher[471]: req:2 'up' [eth0]: new request (0 scripts)
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6632] manager: startup complete
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6626] device (eth0): Activation: successful, device activated.
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6566] policy: set 'Wired connection 1' (eth0) as default for IPv4 routing and DNS
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6565] manager: NetworkManager state is now CONNECTED_SITE
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6558] manager: NetworkManager state is now CONNECTED_LOCAL
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6557] device (eth0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'manag>
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6555] device (eth0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'manage>
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6549] device (eth0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6541] dhcp4 (eth0): state changed unknown -> bound
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6536] dhcp4 (eth0):   gateway 10.10.0.1
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6536] dhcp4 (eth0):   hostname 'server2'
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6536] dhcp4 (eth0):   domain name 'oaks'
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6536] dhcp4 (eth0):   nameserver '10.10.0.1'
May 06 15:47:22 server2 dbus-daemon[439]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.Avahi.service': Unit dbus-org.freedesktop.Avahi.serv>
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6535] dhcp4 (eth0):   expires in 648000 seconds
May 06 15:47:22 server2 dbus-daemon[439]: [system] Activating via systemd: service name='org.freedesktop.Avahi' unit='dbus-org.freedesktop.Avahi.service' requested >
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6535] dhcp4 (eth0):   plen 24
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6535] dhcp4 (eth0):   address 10.10.1.12
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6293] dhcp4 (eth0): activation: beginning transaction (timeout in 45 seconds)
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6284] device (eth0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6275] device (eth0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6262] manager: NetworkManager state is now CONNECTING
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6258] device (eth0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'manage>
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6251] device (eth0): Activation: starting connection 'Wired connection 1' (5b9f0bf9-ed10-31e5-bcad->
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6224] policy: auto-activating connection 'Wired connection 1'
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6206] device (eth0): state change: unavailable -> disconnected (reason 'carrier-changed', sys-iface>
May 06 15:47:22 server2 NetworkManager[440]: <info>  [1525636042.6196] device (eth0): carrier: link connected
May 06 15:47:22 server2 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
May 06 15:47:22 server2 kernel: e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
May 06 15:47:22 server2 udisksd[598]: udisks daemon version 2.7.6 starting
May 06 15:47:22 server2 systemd[1]: Starting Disk Manager...

May 06 15:47:20 server2 systemd[1]: sshd.service: Failed with result 'exit-code'.
May 06 15:47:20 server2 systemd[1]: sshd.service: Main process exited, code=exited, status=255/n/a
May 06 15:47:20 server2 sshd[564]: fatal: Cannot bind any address.
May 06 15:47:20 server2 sshd[564]: error: Bind to port 22 on 10.10.1.12 failed: Cannot assign requested address.
May 06 15:47:20 server2 systemd[1]: Started OpenSSH Daemon.
May 06 15:47:20 server2 systemd[1]: Stopped OpenSSH Daemon.
May 06 15:47:20 server2 systemd[1]: sshd.service: Scheduled restart job, restart counter is at 3.
May 06 15:47:20 server2 systemd[1]: sshd.service: Service hold-off time over, scheduling restart.
May 06 15:47:19 server2 systemd[1]: Startup finished in 12.430s (firmware) + 6.006s (loader) + 8.847s (kernel) + 2.106s (userspace) = 29.391s.
May 06 15:47:19 server2 polkitd[543]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
May 06 15:47:19 server2 systemd[1]: Started Authorization Manager.
May 06 15:47:19 server2 dbus-daemon[439]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
May 06 15:47:19 server2 polkitd[543]: Finished loading, compiling and executing 2 rules
May 06 15:47:19 server2 polkitd[543]: Error compiling script /etc/polkit-1/rules.d/40-allow-passwordless-printer-admin.rules
May 06 15:47:19 server2 polkitd[543]: Loading rules from directory /usr/share/polkit-1/rules.d
May 06 15:47:19 server2 polkitd[543]: Loading rules from directory /etc/polkit-1/rules.d
May 06 15:47:19 server2 polkitd[543]: Started polkitd version 0.114
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.9110] supplicant: wpa_supplicant running
May 06 15:47:19 server2 wpa_supplicant[546]: Successfully initialized wpa_supplicant
May 06 15:47:19 server2 systemd[1]: Started WPA supplicant.
May 06 15:47:19 server2 dbus-daemon[439]: [system] Successfully activated service 'fi.w1.wpa_supplicant1'
May 06 15:47:19 server2 systemd[1]: Started CUPS Scheduler.
May 06 15:47:19 server2 colord[526]: failed to get session [pid 465]: No data available
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8565] device (wlan0): set-hw-addr: set MAC address to 02:6B:94:A4:D1:08 (scanning)
May 06 15:47:19 server2 kernel: IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8563] device (wlan0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'e>
May 06 15:47:19 server2 systemd[1]: sshd.service: Failed with result 'exit-code'.
May 06 15:47:19 server2 sshd[540]: fatal: Cannot bind any address.
May 06 15:47:19 server2 systemd[1]: sshd.service: Main process exited, code=exited, status=255/n/a
May 06 15:47:19 server2 sshd[540]: error: Bind to port 22 on 10.10.1.12 failed: Cannot assign requested address.
May 06 15:47:19 server2 systemd[1]: Starting WPA supplicant...
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8527] manager: (wlan0): new 802.11 WiFi device (/org/freedesktop/NetworkManager/Devices/3)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8521] device (wlan0): driver supports Access Point (AP) mode
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8519] wifi-nl80211: (wlan0): using nl80211 for WiFi device control
May 06 15:47:19 server2 dbus-daemon[439]: [system] Activating via systemd: service name='fi.w1.wpa_supplicant1' unit='wpa_supplicant.service' requested by ':1.1' (u>
May 06 15:47:19 server2 systemd[1]: Starting Authorization Manager...
May 06 15:47:19 server2 systemd[1]: Started OpenSSH Daemon.
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8493] manager: rfkill: WiFi now disabled by radio killswitch
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8492] rfkill1: found WiFi radio killswitch (at /sys/devices/pci0000:00/0000:00:1d.1/0000:05:00.0/ie>
May 06 15:47:19 server2 systemd[1]: Stopped OpenSSH Daemon.
May 06 15:47:19 server2 systemd[1]: sshd.service: Scheduled restart job, restart counter is at 2.
May 06 15:47:19 server2 systemd[1]: sshd.service: Service hold-off time over, scheduling restart.
May 06 15:47:19 server2 dbus-daemon[439]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='polkit.service' requested by ':1.1' (uid=>
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.8479] ovsdb: Could not connect: No such file or directory
May 06 15:47:19 server2 kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

May 06 15:47:19 server2 systemd[1]: sshd.service: Failed with result 'exit-code'.
May 06 15:47:19 server2 systemd[1]: sshd.service: Main process exited, code=exited, status=255/n/a
May 06 15:47:19 server2 sshd[525]: fatal: Cannot bind any address.
May 06 15:47:19 server2 sshd[525]: error: Bind to port 22 on 10.10.1.12 failed: Cannot assign requested address.
May 06 15:47:19 server2 systemd[1]: Starting Manage, Install and Generate Color Profiles...
May 06 15:47:19 server2 systemd[1]: Started OpenSSH Daemon.
May 06 15:47:19 server2 systemd[1]: Stopped OpenSSH Daemon.
May 06 15:47:19 server2 systemd[1]: sshd.service: Scheduled restart job, restart counter is at 1.
May 06 15:47:19 server2 systemd[1]: sshd.service: Service hold-off time over, scheduling restart.
May 06 15:47:19 server2 dbus-daemon[439]: [system] Activating via systemd: service name='org.freedesktop.ColorManager' unit='colord.service' requested by ':1.9' (ui>
May 06 15:47:19 server2 kernel: ath: Regpair used: 0x69
May 06 15:47:19 server2 kernel: ath: Country alpha2 being used: 00
May 06 15:47:19 server2 kernel: ath: EEPROM indicates we should expect a direct regpair map
May 06 15:47:19 server2 kernel: ath: EEPROM regdomain: 0x69
May 06 15:47:19 server2 kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6322] device (eth0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'ex>
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6298] settings: (eth0): created default wired connection 'Wired connection 1'
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6283] keyfile: add connection in-memory (5b9f0bf9-ed10-31e5-bcad-42dadabdcdad,"Wired connection 1")
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6253] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6223] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6207] device (lo): carrier: link connected
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6185] Loaded device plugin: NMOvsFactory (/usr/lib/NetworkManager/libnm-device-plugin-ovs.so)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.6170] Loaded device plugin: NMTeamFactory (/usr/lib/NetworkManager/libnm-device-plugin-team.so)
May 06 15:47:19 server2 kernel: ath10k_pci 0000:05:00.0: htt-ver 3.47 wmi-op 4 htt-op 3 cal otp max-sta 32 raw 0 hwcrypto 1
May 06 15:47:19 server2 kernel: ath10k_pci 0000:05:00.0: Unknown eventid: 90118
May 06 15:47:19 server2 kernel: ath10k_pci 0000:05:00.0: Unknown eventid: 118809
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5679] Loaded device plugin: NMWifiFactory (/usr/lib/NetworkManager/libnm-device-plugin-wifi.so)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5647] Loaded device plugin: NMBluezManager (/usr/lib/NetworkManager/libnm-device-plugin-bluetooth.s>
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5550] Loaded device plugin: NMWwanFactory (/usr/lib/NetworkManager/libnm-device-plugin-wwan.so)

May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5299] Loaded device plugin: NMAtmManager (/usr/lib/NetworkManager/libnm-device-plugin-adsl.so)

May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5276] Loaded device plugin: NMVxlanDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5276] Loaded device plugin: NMVlanDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5276] Loaded device plugin: NMVethDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5276] Loaded device plugin: NMTunDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5276] Loaded device plugin: NMPppDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5276] Loaded device plugin: NMMacvlanDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] Loaded device plugin: NMMacsecDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] Loaded device plugin: NMIPTunnelDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] Loaded device plugin: NMInfinibandDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] Loaded device plugin: NMEthernetDeviceFactory (internal)
May 06 15:47:19 server2 nm-dispatcher[471]: req:1 'hostname': completed: no scripts
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] Loaded device plugin: NMDummyDeviceFactory (internal)
May 06 15:47:19 server2 nm-dispatcher[471]: req:1 'hostname': new request (0 scripts)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] Loaded device plugin: NMBridgeDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] Loaded device plugin: NMBondDeviceFactory (internal)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5275] dhcp-init: Using DHCP client 'internal'
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5274] manager: Networking is enabled by state file
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5274] manager: rfkill: WWAN enabled by radio killswitch; enabled by state file
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5273] manager: rfkill: WiFi enabled by radio killswitch; disabled by state file

May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.5267] settings: loaded plugin iBFT: (c) 2014 Red Hat, Inc.  To report bugs please use the NetworkMa>

May 06 15:47:19 server2 ntpd[458]: Command line: /usr/bin/ntpd -g -u ntp:ntp
May 06 15:47:19 server2 ntpd[458]: ntpd 4.2.8p11@1.3728-o Wed Mar  7 18:48:03 UTC 2018 (1): Starting


May 06 15:47:19 server2 systemd[1]: Started Network Manager Script Dispatcher Service.
May 06 15:47:19 server2 dbus-daemon[439]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'

May 06 15:47:19 server2 systemd[1]: sshd.service: Failed with result 'exit-code'.
May 06 15:47:19 server2 systemd[1]: sshd.service: Main process exited, code=exited, status=255/n/a
May 06 15:47:19 server2 sshd[463]: fatal: Cannot bind any address.
May 06 15:47:19 server2 sshd[463]: error: Bind to port 22 on 10.10.1.12 failed: Cannot assign requested address.
May 06 15:47:19 server2 systemd[1]: Started Simple Desktop Display Manager.
May 06 15:47:19 server2 autossh[462]: ssh child pid is 476
May 06 15:47:19 server2 systemd[1]: Started Permit User Sessions.
May 06 15:47:19 server2 autossh[462]: starting ssh (count 1)
May 06 15:47:19 server2 autossh[462]: port set to 0, monitoring disabled
May 06 15:47:19 server2 autossh[468]: ssh child pid is 475
May 06 15:47:19 server2 autossh[468]: starting ssh (count 1)
May 06 15:47:19 server2 autossh[461]: ssh child pid is 474
May 06 15:47:19 server2 autossh[459]: ssh child pid is 473
May 06 15:47:19 server2 autossh[461]: starting ssh (count 1)
May 06 15:47:19 server2 autossh[460]: ssh child pid is 472
May 06 15:47:19 server2 autossh[459]: starting ssh (count 1)
May 06 15:47:19 server2 autossh[460]: starting ssh (count 1)
May 06 15:47:19 server2 systemd[1]: Starting Network Manager Script Dispatcher Service...
May 06 15:47:19 server2 autossh[466]: ssh child pid is 470
May 06 15:47:19 server2 autossh[466]: starting ssh (count 1)
May 06 15:47:19 server2 autossh[468]: port set to 0, monitoring disabled
May 06 15:47:19 server2 autossh[461]: port set to 0, monitoring disabled
May 06 15:47:19 server2 autossh[459]: port set to 0, monitoring disabled
May 06 15:47:19 server2 autossh[460]: port set to 0, monitoring disabled
May 06 15:47:19 server2 autossh[466]: port set to 0, monitoring disabled
May 06 15:47:19 server2 systemd[1]: Starting Permit User Sessions...
May 06 15:47:19 server2 systemd[1]: Starting CUPS Scheduler...
May 06 15:47:19 server2 systemd[1]: Started OpenSSH Daemon.
May 06 15:47:19 server2 dbus-daemon[439]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.ser>
May 06 15:47:19 server2 systemd[1]: Starting Network Time Service...
May 06 15:47:19 server2 systemd[1]: Reached target Network.
May 06 15:47:19 server2 systemd[1]: Started Network Manager.
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.4679] manager[0x5631afba8080]: rfkill: WWAN hardware radio set enabled
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.4678] manager[0x5631afba8080]: rfkill: WiFi hardware radio set disabled
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.4674] dns-mgr[0x5631afbc3130]: init: dns=default, rc-manager=symlink
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.4672] hostname: hostname changed from (none) to "server2"
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.4672] hostname: hostname: using hostnamed
May 06 15:47:19 server2 systemd[1]: Started Hostname Service.
May 06 15:47:19 server2 dbus-daemon[439]: [system] Successfully activated service 'org.freedesktop.hostname1'
May 06 15:47:19 server2 kernel: input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input19
May 06 15:47:19 server2 kernel: input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input18
May 06 15:47:19 server2 kernel: input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input17
May 06 15:47:19 server2 kernel: input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input16
May 06 15:47:19 server2 systemd[1]: Starting Hostname Service...
May 06 15:47:19 server2 dbus-daemon[439]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' re>
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.1725] manager[0x5631afba8080]: monitoring kernel firmware directory '/usr/lib/firmware'.
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.1684] Read config: /etc/NetworkManager/NetworkManager.conf (lib: 20-connectivity.conf)
May 06 15:47:19 server2 NetworkManager[440]: <info>  [1525636039.1683] NetworkManager (version 1.10.6-3, Arch Linux) is starting... (for the first time)
May 06 15:47:19 server2 systemd-logind[441]: Watching system buttons on /dev/input/event4 (  USB Keyboard)
May 06 15:47:19 server2 systemd-logind[441]: Watching system buttons on /dev/input/event3 (  USB Keyboard)
May 06 15:47:19 server2 systemd-logind[441]: Watching system buttons on /dev/input/event0 (Sleep Button)
May 06 15:47:19 server2 systemd-logind[441]: Watching system buttons on /dev/input/event1 (Power Button)
May 06 15:47:19 server2 systemd-logind[441]: Watching system buttons on /dev/input/event2 (Power Button)
May 06 15:47:19 server2 systemd-logind[441]: New seat seat0.
May 06 15:47:19 server2 systemd[1]: Reached target Timers.
May 06 15:47:19 server2 systemd[1]: Started Daily man-db cache update.
May 06 15:47:19 server2 systemd[1]: Started Daily verification of password and group files.
May 06 15:47:19 server2 systemd[1]: Started Daily Cleanup of Snapper Snapshots.
May 06 15:47:19 server2 systemd[1]: Started Daily autocommit of changes in /etc directory.
May 06 15:47:19 server2 systemd[1]: Starting Login Service...
May 06 15:47:19 server2 systemd[1]: Starting Network Manager...
May 06 15:47:19 server2 systemd[1]: Started D-Bus System Message Bus.
May 06 15:47:19 server2 systemd[1]: Reached target Basic System.
May 06 15:47:19 server2 systemd[1]: Reached target Sockets.
May 06 15:47:19 server2 systemd[1]: Listening on CUPS Scheduler.
May 06 15:47:19 server2 systemd[1]: Listening on D-Bus System Message Bus Socket.
May 06 15:47:19 server2 systemd[1]: Started Daily Cleanup of Temporary Directories.
May 06 15:47:19 server2 systemd[1]: Started Timeline of Snapper Snapshots.
May 06 15:47:19 server2 systemd[1]: Reached target Paths.
May 06 15:47:19 server2 systemd[1]: Started CUPS Scheduler.
May 06 15:47:19 server2 systemd[1]: Started Daily rotation of log files.
May 06 15:47:19 server2 systemd[1]: Reached target System Initialization.
May 06 15:47:19 server2 systemd[1]: Started Update UTMP about System Boot/Shutdown.
May 06 15:47:19 server2 systemd[1]: Starting Update UTMP about System Boot/Shutdown...
May 06 15:47:19 server2 systemd[1]: Started Create Volatile Files and Directories.
May 06 15:47:19 server2 systemd[1]: Starting Create Volatile Files and Directories...
May 06 15:47:19 server2 systemd[1]: Started Flush Journal to Persistent Storage.
May 06 15:47:18 server2 systemd[1]: Reached target Sound Card.

/usr/lib/systemd/system/sshd.service:

[Unit]
Description=OpenSSH Daemon
Wants=sshdgenkeys.service
After=sshdgenkeys.service
After=network.target

[Service]
ExecStart=/usr/bin/sshd -D
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always

[Install]
WantedBy=multi-user.target

# This service file runs an SSH daemon that forks for each incoming connection.
# If you prefer to spawn on-demand daemons, use sshd.socket and sshd@.service.

/etc/NetworkManager/NetworkManager.conf is empty and /etc/NetworkManager/conf.d/ is empty.

Noteable log entries:

  • May 06 15:47:22 server2 kernel: e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
  • May 06 15:47:19 server2 systemd[1]: sshd.service: Failed with result 'exit-code'.
  • May 06 15:47:19 server2 systemd[1]: Reached target Network.

It appears that the system is reaching target Network before the actual interface is up. How is this resolved?

  • 1
    May 06 15:47:19 server2 sshd[540]: error: Bind to port 22 on 10.10.1.12 failed: Cannot assign requested address. probably means ListenAddress was changed from the default. If sshd didn't try to bind to a specific address it wouldn't have any trouble. There's still firewall or host.allow if needed – A.B May 6 at 22:24
up vote 3 down vote accepted

As A.B indicated, your ssh config has likely been adjusted to listen on a specific IP address. If that IP address is not available when sshd starts, then the service will fail.
By default, sshd is configured to liste on 0.0.0.0, which means any address, and thus doesn't depend on a specific IP being available.

There are 2 ways you can address this:

Start after network-online.target

systemd provides a network-online.target unit for services which need the network to be fully up (all interfaces configured). Thus you can make sshd start after this unit to start up after the interface is configured

mkdir /etc/systemd/system/sshd.service.d

cat > /etc/systemd/system/sshd.service.d/network-online.conf <<EOF
[Unit]
After=network-online.target
EOF

systemctl daemon-reload

Allow binding to non-local addresses

The other option is to allow listening on addresses which are not present on the host.
This solution is system wide, so will apply to any service, not just sshd.

echo 'net.ipv4.ip_nonlocal_bind = 1' > /etc/sysctl.d/99-nonlocal_bind.conf

systemctl restart systemd-sysctl.service
  • I'll try replacing After=network.target with After=network-online.target. It strikes me that this should be the default behavior anyway. The listen address was changed to tighten security, and I prefer to leave as is. I have other computers that work fine with a specific listen address specified. This computer must have more delay than the others in obtaining an address via DHCP. – MountainX May 7 at 1:26
  • Instead of manually creating the drop-in directory and file for sshd.service, you can also use systemd edit sshd.service (prepending sudo as required.) The main difference is that the resulting file is always called override.conf, and the unit is automatically reloaded if you commit the changes. – ErikF May 7 at 4:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.