Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

what is the command to run ssh on port 1337 or alternate port?

share|improve this question

sshd with -p PORT:

-p port Specifies the port on which the server listens for connections (default 22). Multiple port options are permitted. Ports specified in the configuration file with the Port option are ignored when a command-line port is specified. Ports specified using the ListenAddress option override commandline ports.

You can edit sshd config(/etc/ssh/sshd_config):

Port 1337
share|improve this answer

You want the Port directive in the sshd_config file, or alternatively sshd -p.
See man sshd & man sshd_config for more information.

share|improve this answer

You should read man sshd or man sshd.conf it is quite clear.

share|improve this answer
isn't there a command i can run per each instance of ssh? – HollerTrain Jan 31 '11 at 18:45
No because you'd have to connect first then change port – Jacob Jan 31 '11 at 18:48
ssh -p 2222 – HollerTrain Jan 31 '11 at 19:12

Just change the (possibly commented, in which case you obviously need to uncomment it) "Port 22" line in your ssh server configuration file to "Port 1337".

share|improve this answer
i only have one client that uses port 1337, other use regular port so i would rather just use the command line to connect that port each time – HollerTrain Jan 31 '11 at 18:48
ssh -p 2222 – HollerTrain Jan 31 '11 at 18:54
Do you want to connect to an ssh server running on port 1337, or do you want to run a server on that particular port? You comment seems to indicate the former while the original question seems to indicate the latter. – lmontrieux Jan 31 '11 at 19:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.