Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

If the admin doesn't set the ssh service port on default 22, how can I find the port that he set? Trust me I don't plan to doing bad things. I am just curious!

update: The ssh service port is on 521. I can be sure. Because i can use ssh login via 521.
nmap addresshided -sV
Starting Nmap 5.51 ( ) at 2011-09-30 09:38 CST
Nmap scan report for addresshided
Host is up (0.0052s latency).
Not shown: 996 filtered ports
23/tcp  closed telnet
80/tcp  closed http
443/tcp closed https
631/tcp closed ipp

Service detection performed. Please report any incorrect results at .
Nmap done: 1 IP address (1 host up) scanned in 5.45 seconds

I think i need to study nmap further. Thank you for all the reply. :-)

share|improve this question
this comes up blank? >nmap -P0 -p521 ip – barlop Sep 30 '11 at 1:57
up vote 4 down vote accepted
nmap [ip] -sV

or, if on the local machine:

netstat -tlp | grep -i ssh
share|improve this answer
+1 for the correct answer. ;) – Doc Sep 29 '11 at 14:16
Good answer, but why the backticks? what's the output being used for? Typing this as shown will give you odd errors. I know this is nit-picky, but the cmd line IS picky... especially since naive people will type it exactly as shown, just as they've been taught since day one. – lornix Sep 29 '11 at 20:28
@Sirex, It doesn't work. – LouXiu Sep 30 '11 at 1:46

Seriously, send them an email and ask.

share|improve this answer
+1. Simple solution to a simple problem. Unauthorized port scans are against terms and conditions within certain networks too. – Jin Sep 30 '11 at 1:53

You can use this easy to use online tool port scanner. It will list out all the open ports and what are the configured for.
You could use the following commands :

$ lsof
This lists out all you open ports
$ netstat -nan | grep 22
This will give you detail of theport specified

share|improve this answer
22 "SSH"-Port is closed. But the ssh service is on 521. I am sure it is open. Because i can login. – LouXiu Sep 29 '11 at 14:07
@LouXiu so problem solved, isn't it? Or did I miss something? – woliveirajr Sep 29 '11 at 14:10
@woliveirajr, =.= No... that port scanner's result is not even include 512. I know the ssh service is on 512. lsof and netstat works if i login the server. But if i am not in the server. How can i do it? – LouXiu Sep 29 '11 at 14:15
have you tried my answer, using some app to do that ? – woliveirajr Sep 29 '11 at 14:19
@woliveirajr, I tried that port scanner. – LouXiu Sep 30 '11 at 1:40

Run the following in a terminal:

lsof | grep IPv4 | grep ssh
  1. lsofwill list all open files and ports.
  2. grep IPv4 weeds out everything except open IP sockets
  3. grep ssh shows only lines with ssh.

If you look through the results, you should be able to find which ports are in use by the ssh process.

share|improve this answer
This will only work locally, correct? If so, I suppose one couldn't necessarily open the ssh config read-only.. Interesting answer. :) – Doc Sep 29 '11 at 14:17
@Doc: Ha, you're right. It didn't even occur to me the asker might not be on the computer he's asking about. – Stephen Jennings Oct 1 '11 at 15:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .