0

I am able to ssh to the machine.
But my machine not shown as listening on port 22.
Below is what I see.
It show as listening on port 53, 21, 8080, 8443 etc. But no entry for 22(ssh).
My machine IP is 10.8.113.30. OS is windriver linux.
Why is this?

netstat -antu | grep LISTEN 
tcp        0      0 127.0.0.1:8083          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:8084          0.0.0.0:*               LISTEN     
tcp        0      0 10.8.113.30:8021        0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:8021          0.0.0.0:*               LISTEN     
tcp        0      0 10.8.113.30:21          0.0.0.0:*               LISTEN     
tcp        0      0 10.8.113.30:53          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:3128            0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN     
tcp        0      0 10.8.113.30:8443        0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN     
tcp        0      0 10.8.113.30:8128        0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:8128          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25255         0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:5001            0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:5580            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:5581            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 10.8.113.30:8080        0.0.0.0:*               LISTEN     
tcp        0      0 10.8.113.30:81          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:81            0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:8021                :::*                    LISTEN     
tcp6       0      0 :::53                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 :::3128                 :::*                    LISTEN     
tcp6       0      0 ::1:8128                :::*                    LISTEN     
tcp6       0      0 127.0.0.1:18081         :::*                    LISTEN     
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 ::1:81                  :::*                    LISTEN     
  • It's listening on the IPv6 port 22. – Kusalananda Nov 6 '17 at 10:57
  • On freebsd it used to show the exact IP address. Isn't that the case with linux? Exact IP address would really help. Anyway to get the same? – BRT Nov 6 '17 at 11:03
4

You machine is listening to port 22. Here's the line:

tcp6       0      0 :::22                   :::*                    LISTEN 

The socket is listening for both IPv6 and IPv4 connections.

  • On freebsd it used to show the exact IP address. Isn't that the case with linux? Exact IP address would really help. Anyway to get the same? – BRT Nov 6 '17 at 11:02
  • A process can listen on a specific interface address, or it can use INADDR_ANY or INADDR6_ANY, which means is accepts connections on all interfaces. Linux by default listens on both IPV4 and IPv6 connections if INADDR6_ANY (::) is used. – Johan Myréen Nov 6 '17 at 11:05
  • My idea is to look for interfaces listening on port 22 and establish a ssh tunnel with tunnel server using a particular interface IP. So I am looking for IP address here.. In freebsd I see that we get this info with netstat command - netstat -na -p tcp -f inet | grep LISTEN. Anyways to get the IP on linux too? Also, pointing at your sentence -> "Linux by default listens on both IPV4 and IPv6 connections if INADDR6_ANY (::) is used".. Is it safe to get the ip address from ifconfig's output and use this to establish tunnel as you say that linux by default listens on both IPV4/6" – BRT Nov 6 '17 at 11:18
  • To listen on a specific address only, you will have to configure the ssh server to listen to that address only. For example, you could put this in /etc/ssh/sshd_config: ListenAddress 10.8.113.30. This forces the ssh server to only listen on that address. – Johan Myréen Nov 6 '17 at 11:28
  • @BRT: The point is that in this specific case the SSH daemon is not listening on a specific address; it's listening on any address. Poor netstat shows the truth. – AlexP Nov 6 '17 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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