What it the min/max port range for SSH?

The other answers mistakenly seem to suggest that it is OK to use a service port which isn't used on your machine (as seen from the output of nmap localhost). It is not! This because:

  1. if you add that particular service later, it's going to conflict with the SSH server and you're going to be into trouble, and
  2. services that run on another registered service port are guaranteed to cause confusion.

For instance in Mohsen's output there is no service running on TCP port 143 so you might think that you could use that port for your SSH server. However, the day you also install a IMAP mailserver, it will conflict with it.

You should run SSH on an unprivileged port number, i.e. from 1024 to 65535, and avoid IANA registered service numbers (you can get the same list via the shell command cat /etc/services). It is usually also a good idea to choose a new port number that reminds the original port; for instance, in this case, 10022 or 22022.


You can choose any other port to your liking, e.g. anything between 0 and 65535 (0 … 2¹⁶-1).

You can get the information for registered ports from /etc/services or something like wikipedia.

Tags:

Ssh

Tcp