Can I have ssh listen on multiple ports on different ips?

Yes, the Port and ListenAddress option can be listed multiple times. ListenAddress can also contain the port setting as well as the ip.



Here is an example using a few combinations of each option.


root@root [/etc/ssh]# diff sshd_config sshd_config.save

13,14c13

< Port 22

< Port 44

—-

> #Port 22

16c15

< ListenAddress 0.0.0.0

—-

> #ListenAddress 0.0.0.0

18,20d16

< ListenAddress 10.0.0.1:2000

< ListenAddress 10.0.0.1:2001

< ListenAddress 10.0.0.2:3000

root@root [/etc/ssh]# /etc/init.d/sshd restart

Stopping
sshd:                                            
OK  ]


Starting
sshd:                                            
OK  ]


root@root [/etc/ssh]# netstat -anp | grep LISTEN.*sshd

tcp       
0      0
0.0.0.0:44                 
0.0.0.0:*                  
LISTEN      1996/sshd


tcp       
0      0
10.0.0.1:2000              
0.0.0.0:*                  
LISTEN      1996/sshd


tcp       
0      0
10.0.0.1:2001              
0.0.0.0:*                  
LISTEN      1996/sshd


tcp       
0      0
0.0.0.0:22                 
0.0.0.0:*                  
LISTEN      1996/sshd


tcp       
0      0
10.0.0.2:3000              
0.0.0.0:*                  
LISTEN      1996/sshd



Your rating: None Average: 4 (2 votes)