Bug#764842: systemd socket file does not recognise port setting
Package: openssh-server
Version: 1:6.7p1-2
While openssh should use the port specified in /etc/ssh/sshd_config, the
systemd socket file is hard coded with ListenStream=22. Because changes
in /lib/systemd/system/ssh.socket are overwritten by updates of the
openssh-server package, the postinst script should make sure that the
port of sshd_config is also used in ssh.socket.
As simple workaround I changed the postinst script as follows from line
281 to call a new function set_port_in_ssh_socket:
if [ "$action" = configure ]; then
create_sshdconfig
set_port_in_ssh_socket
create_keys
fix_statoverride
setup_sshd_user
Which looks like that:
set_port_in_ssh_socket() {
listenport=$(grep Port /etc/ssh/sshd_config | cut -d ' ' -f 2)
systemdsocketfile=$(sed
"s/ListenStream=22/ListenStream=$listenport/"
/lib/systemd/system/ssh.socket)
echo "$systemdsocketfile" > /lib/systemd/system/ssh.socket
}
The code (also attached) is not beautiful and I'm not sure whether this
is the right place to do it. But at least that way people upgrading from
wheezy to jessie have sshd running on the same port if they changed it
in sshd_config before ;)
Regards,
Kai
265a266,271
> set_port_in_ssh_socket() {
> listenport=$(grep Port /etc/ssh/sshd_config | cut -d ' ' -f 2)
> systemdsocketfile=$(sed "s/ListenStream=22/ListenStream=$listenport/" /lib/systemd/system/ssh.socket)
> echo "$systemdsocketfile" > /lib/systemd/system/ssh.socket
> }
>
282a289
> set_port_in_ssh_socket
Reply to: