Thanks for the logs. It's a conundrum at the moment for me. I don't know whether any of the following will help, but here it is.
Your code outputs:
Code:
konstantinos@AsusX570:/etc/init.d$ sudo lsof -i -P -n | grep LISTEN
systemd 1 root 164u IPv6 1*155 0t0 TCP *:22 (LISTEN)
On my machine the output is:
Code:
[root@owl ~]# lsof -i -P -n | grep LISTEN
sshd 747 root 3u IPv4 14913 0t0 TCP *:22 (LISTEN)
PID 1, which is listening on port 22 on your machine, keeping it busy, is /sbin/init, which is a link to /lib/systemd/systemd which is the command that initialises the system and stays live until shutdown. Since it's stays live, having "grabbed" or "bound" port 22, presumably it won't release it. On my output, sshd has it's own PID of 747.
The command that runs sshd from startup configured in /lib/systemd/system on my machine is:
Code:
[ben@owl ~]$ cat /proc/747/cmdline
sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
The PID 1 command is, predictably:
Code:
[ben@owl ~]$ cat /proc/1/cmdline
/sbin/init
I guess your PID 1 will be the same.
The systemd configuration for sshd is:
Code:
[ben@owl /lib/systemd/system]$ cat ssh.service
[Unit]
Description=OpenBSD Secure Shell server
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sshd.service
I guess your config won't be different.
It seems odd to me that PID 1 would take over port 22 which is the standard listening port for sshd. It's not possible to remove PID 1 in order to free up port 22. If it was some other process that had grabbed port 22, removing it may have been a resolution.
It's possible to change the port for sshd in /etc/ssh/sshd_config and use it on a port that is otherwise not used. That at least would likely allow usage of ssh.