If all ListenAddress lines in the sshd_config file specify
a port, then the -p option to sshd is silently ignored:
# cat test_sshd_config2
ListenAddress 0.0.0.0:22
ListenAddress 0.0.0.0:2222
# `pwd`/sshd -D -d -p 4411 -f test_sshd_config2
debug1: sshd version OpenSSH_4.2p1
debug1: private host key: #0 type 0 RSA1
debug1: read PEM private key done: type RSA
debug1: private host key: #1 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #2 type 2 DSA
debug1: rexec_argv[0]='/path/to/sshd'
debug1: rexec_argv[1]='-D'
debug1: rexec_argv[2]='-d'
debug1: rexec_argv[3]='-p'
debug1: rexec_argv[4]='4411'
debug1: rexec_argv[5]='-f'
debug1: rexec_argv[6]='test_sshd_config2'
debug1: Bind to port 2222 on 0.0.0.0.
debug1: Bind to port 22 on 0.0.0.0.
Bind to port 22 on 0.0.0.0 failed: Address already in use.
Cannot bind any address.
# ^D
This seems... counterintuitive, at least. Is it the
intended behaviour?
--
``Around 1,500 spectators turned up,... lured by the novel combination of
death, an elephant and electricity. Mercifully, Topsy died extremely quickly,
and without a trumpet, which may have had something to do with the carrots
laced with cyanide that she had been fed.'' (from The Economist)