Create account Login Webmail Contact Us

How to setup SSH to listen on multiple/one IP and Ports
Posted by Mike C. on 11 September 2009 11:56 PM
This can be a very easy task if you know how to do it correctly and follow my steps EXACTLY as I show them to you. First thing you want to make sure nothing is going to be blocking the port(s) and/or IP(s) you want to use for SSH (firewalls etc). Once you have made sure nothing will restrict SSH access then you may proceed. You will want to open up /etc/ssh/sshd_config (if your sshd_config is somewhere else because you installed it from /usr/ports you will need to open the one that pertains to the SSH application you run). You will see in the file that there is something similar to this:

#Port 22
#Protocol 2
#ListenAddress ::

You will need to be root to edit the file to read like this in order for it to be on the particular IP(s) of your choice and the particular Port(s) of your choice:

Port 22
Port 35353
Port 35354


This config will listen on both and on all three of those ports. You will notice you have to have a completely seperate entry for each port and address. This is not true with all BSD programs but it is with this particular program (openssh). If you wanted SSH to listen on all addresses you could just leave "ListenAddress" commented out (With a # in front of it). There are many other great options with openssh but I would not suggest you blindly change options without first reading about what they do.

After you have edited the config file you will save it and exit out. You need to find the PID of the SSHD process to kill it and it alone. Type "ps aux | grep sshd" and find the sshd process which should look something like this:

root 75830 0.0 0.1 2656 1792 ?? Is 22Apr06 1:01.30 /usr/sbin/sshd

The PID will be the first number which is, in this case, 75830. You will then type "kill -9 75830 ; /usr/sbin/sshd". You will notice I specified /usr/sbin/sshd because thats is where my SSHD program is. If you have a different directory structure you will need to specify otherwise. Once you have done this SSHD will be back up (or should be). To be SURE you need to try and login (DON'T LOGOUT OF YOUR ORIGINAL SESSION WHATEVER YOU DO). If you can login then the operation was a success. If you can't login you will need to revert back to old settings or trouble shoot the sshd_config. I wouldn't suggest doing this if you are sure you can pull it off. If you are brand new to BSD I always recommend you read the FreeBSD handbook.
(407 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name: