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.
from the host side: https://unix.stackexchange.com/questions/54975/how-to-check-that-a-daemon-is-listening-on-what-interface
– Florian Castellane – 2018-05-18T08:43:32.577ss -nlput | grep sshd
will showtcp LISTEN 0 0 *:22 *:* sshd 1234 42
-> port 22After 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