Port forwardings are duplicated when connecting to host by nickname

Sebastian Ratz sebastian.ratz at student.kit.edu
Thu Jan 29 05:23:58 AEDT 2015


Hello,

I found a problem with port forwardings specified in the
config file.

The following is run on OpenSSH 6.7p1:


Assume the following ~/.ssh/config:

Host some.host.name.com foo
    Hostname some.host.name.com
    DynamicForward 55555


When connecting to the real hostname everything is fine:

$ ssh -v some.host.name.com
...
debug1: Local connections to LOCALHOST:55555 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 55555.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 55555.
debug1: channel 1: new [port listener]
...


But when using the short nickname:

$ ssh -v foo
...
debug1: Hostname has changed; re-reading configuration
...
debug1: Local connections to LOCALHOST:55555 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 55555.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 55555.
debug1: channel 1: new [port listener]
debug1: Local connections to LOCALHOST:55555 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 55555.
bind: Address already in use
debug1: Local forwarding listening on 127.0.0.1 port 55555.
bind: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 55555
...


The reason is that in the second case OpenSSH reparses the config
and then tries to adds the same forwarding rules again.


I looked into the source and there is a method compare_forward()
in mux.c that is used to prevent adding of duplicates.
Maybe that should be used also when parsing the config or
commandline in ssh.c / readconf.c?


Regards,
Sebastian


More information about the openssh-unix-dev mailing list