0

Ok,

so here's the deal. I setup an Iptables rule as follows:

IPTABLES -A INPUT -p tcp --dport 51722 -j ACCEPT

and if I do systemctl status sshd.service, I get the following:

Server listening on 0.0.0.0 port 51722.

Ok. That's what I want. I then ssh as such ssh -p 51722 root@MY.IP.ADDRESS

once I login, I check status of sshd again and notice.

Accepted password for root from MY.IP.ADDRESS port 49344 ssh2

Why is it showing that it is on Port 49344 as opposed to 51722?

1

This is because ssh uses ephemeral ports.The logged port is port that the client is using to connect, not the port the server accepted the connection on.

Your netstat -tp output will have a line similar too:

tcp    0    0 server.example.com:51722    client.example.com:49344    ESTABLISHED 15825/sshd
1
  • ah, ok cool. didn't know about ephemeral ports. Mar 9 '15 at 20:49

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.