By default only one port (port number 22) will be enabled as ssh/scp port in Linux
SSH is a widely used protocol for system administration and file transfer. In addition, it has a feature called SSH tunnelling (or SSH port forwarding). It creates an encrypted connection between. If you have not specified a port, the SSHD, by default, then it will work on the previously specified addresses and port options. You can also allow multiple listenaddress and options in sshdconfig. For running SSH on a non-standard port # 2022 using Port option, use the following command.
Ssh Multiple Ports
To enable multiple ssh ports we need to tweak /etc/ssh/sshd_config file.
Open /etc/ssh/sshd_config with any editor and search for line Port 22. Below this line add a new port which you want to use.
Example: I would like to use 12345 as another ssh port, add it as shown below.
Save and exit from /etc/ssh/sshd_config file.

Sshd Listen On Multiple Ports
Restart sshd service with following command:
After restarting sshd service test try to login/ssh with new port 12345, it should work.
Sshd Listen Multiple Ports
You can also check list of ports opened for ssh using following command where you can see port 22 and 12345 in output:


Output:
-Sany
I wanted to configure a sshd on my home Mac recently to be able to access it remotely and decided to follow best practice and change port from default value 22/tcp, which is quite an easy task to do on any *nix system.It turned out that Apple changed service startup process in Mac OS X 10.4 (Tiger) to what is called launchd. So you may guess that changing port number in /etc/sshd_config didn't help and there was no /etc/inetd.conf or xinetd equivalent. At this point it became more interesting.
Finally I've come to the following procedure:
- Add a new service to the /etc/services file. I've called it ssh-NNNN, where NNNN is desired port number (this name is not a requirement and is only for clarity). So I've got a new line like:
ssh-NNNN NNNN/tcp
in /etc/services.
- Find a file named ssh.plist in /System/Library/LaunchDaemons. In this file find the following text:
and change ssh to a new service name ssh-NNNN.<key>SockServiceName</key> <string>ssh</string>
- That's it. Now just start or restart SSH service from the System Preferences. Also, don't forget to open required port on the firewall (I leave this up to you)!
