ssh.service and ssh.socket both running.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openssh (Ubuntu) |
Fix Released
|
Undecided
|
Colin Watson |
Bug Description
I am running Ubuntu 23.04. The out-of-the-box configuration allows SSH access on port 22. I wish to have ssh listen on both ports 22 and 7022. The ssh_config file contains a comment that Ubuntu now uses socket activated connections and thus ignores the Port and ListenAddress entries. I looked up the ssh socket activation and found that I needed a /etc/systemd/
[Socket]
# Uncomment the following line to turn of listening on port 22.
#ListenStream=
ListenStream=7022
I then ran these two commands:
sudo systemctl daemon-reload
sudo systemctl restart ssh
I then checked for port listeners:
root# lsof -i -P -n | grep LISTEN
systemd 1 root 454u IPv6 25979 0t0 TCP *:22 (LISTEN)
systemd-r 638 systemd-resolve 14u IPv4 35332 0t0 TCP 127.0.0.53:53 (LISTEN)
systemd-r 638 systemd-resolve 16u IPv4 35334 0t0 TCP 127.0.0.54:53 (LISTEN)
Xtigervnc 941 moose 9u IPv4 22485 0t0 TCP 127.0.0.1:5902 (LISTEN)
Xtigervnc 941 moose 10u IPv6 22486 0t0 TCP [::1]:5902 (LISTEN)
cupsd 2258639 root 6u IPv6 33526334 0t0 TCP [::1]:631 (LISTEN)
cupsd 2258639 root 7u IPv4 33526335 0t0 TCP 127.0.0.1:631 (LISTEN)
sshd 3698765 root 3u IPv6 25979 0t0 TCP *:22 (LISTEN)
I then discovered that both ssh.service and ssh.socket are running:
root@/etc/netplan# systemctl status ssh.service
? ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/
Drop-In: /etc/systemd/
Active: active (running) since Tue 2023-05-23 11:17:29 EDT; 36min ago
TriggeredBy: ? ssh.socket
Docs: man:sshd(8)
Process: 3698763 ExecStartPre=
Main PID: 3698765 (sshd)
Tasks: 3 (limit: 38046)
Memory: 3.6M
CPU: 206ms
CGroup: /system.
May 23 11:51:44 alces sshd[3771657]: ...
Hint: Some lines were ellipsized, use -l to show in full.
root@/etc/netplan# systemctl status ssh.socket
? ssh.socket - OpenBSD Secure Shell server socket
Loaded: loaded (/lib/systemd/
Drop-In: /etc/systemd/
Active: active (running) since Mon 2023-05-15 09:23:44 EDT; 1 week 1 day ago
Until: Mon 2023-05-15 09:23:44 EDT; 1 week 1 day ago
Triggers: ? ssh.service
Listen: [::]:22 (Stream)
Tasks: 0 (limit: 38046)
Memory: 8.0K
CPU: 569us
CGroup: /system.
May 15 09:23:44 alces systemd[1]: ...
Hint: Some lines were ellipsized, use -l to show in full.
Finally, I found that /lib/systemd/system contains both ssh.service and ssh.socket configurations.
ssh.service:
[Unit]
Description=OpenBSD Secure Shell server
Documentation=
After=network.
ConditionPathEx
[Service]
EnvironmentFile
ExecStartPre=
ExecStart=
ExecReload=
ExecReload=
KillMode=process
Restart=on-failure
RestartPreventE
Type=notify
[Install]
WantedBy=
Alias=sshd.service
ssh.socket:
[Unit]
Description=OpenBSD Secure Shell server socket
Before=
ConditionPathEx
[Socket]
ListenStream=22
Accept=no
[Install]
WantedBy=
Finally, in /etc/systemd/system there is an ssh.service.d directory that contains the 00-socket.conf file that contains:
[Unit]
After=ssh.socket
Requires=ssh.socket
This is very confusing. I could disable ssh.service, but I am concerned that if I do this I will lose ssh connectivity to my headless server. What is the way out of this morass? It would be VERY helpful if there was a comprehensive guide to the current ssh configuration that explains what services to run, how to configure those services, and where the configuration files should reside.
Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https:/ /wiki.ubuntu. com/Bugs/ FindRightPackag e. You might also ask for help in the #ubuntu-bugs irc channel on Libera.chat.
To change the source package that this bug is filed about visit https:/ /bugs.launchpad .net/ubuntu/ +bug/2020560/ +editstatus and add the package name in the text box next to the word Package.
[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]