Find the port number of current session in PuTTY

8

1

I have list of server names in the PuTTY saved sessions. I connected to one session and can know the IP address of the machine connected to using ifconfig for Ubuntu and ipconfig for Windows. But how to know the port number which has been used in to save those sessions in PuTTY while/after connecting?

I tried echo "$SSH_CLIENT" but didn't get the right IP, so, the port might also be wrong.

Ac3_DeXt3R

Posted 2018-05-18T06:06:04.547

Reputation: 1 012

from the host side: https://unix.stackexchange.com/questions/54975/how-to-check-that-a-daemon-is-listening-on-what-interface ss -nlput | grep sshd will show tcp LISTEN 0 0 *:22 *:* sshd 1234 42 -> port 22

– Florian Castellane – 2018-05-18T08:43:32.577

After reading your answer, I'd like you to clarify the question. The standard ssh port is 22, so the question sounds like you want to know the port the client used when setting up the connection to server 22. But the answer answers how to find out which server port you connected to, instead of 22. This makes sense in some cases - many virtual host providers give your vhost an ipv6, address, and very few forwarded ipv4 ports, so selecting the ssh server port determines which vhost you're connecting to - but that's not what the typical reader of your question would expect. – Guntram Blohm supports Monica – 2018-05-18T16:25:48.843

Answers

3

To answer your literal question: To find an IP address and a port number of the current session:

  • Right click PuTTY console window title;
  • Select Event Log;
  • The very first entry in the log says:

    Connecting to <ip> port <port>
    

    enter image description here


Though in majority of cases the port will be 22, as that's the standard SSH port.

Martin Prikryl

Posted 2018-05-18T06:06:04.547

Reputation: 13 764

Please read the question properly. – Ac3_DeXt3R – 2018-05-19T03:12:34.070

1I read it. Is there anything wrong with my answer? – Martin Prikryl – 2018-05-19T05:18:35.573

1You are right, I got confused with "and a port number of the current session:" and my query for the server which I want to connect. Never mind. :) – Ac3_DeXt3R – 2018-05-20T06:15:12.147

8

After spending some time with putty, I figured out myself.

In putty configuration, click name in the Saved Sessions, then click Load button, one can see the port number in the above Port field.

Open Putty -> select Session -> Load -> See the Port Field

Sometimes, simple things just doesn't get easily caught with our eyes.

Ac3_DeXt3R

Posted 2018-05-18T06:06:04.547

Reputation: 1 012