I've noted this entry in auth.log
Accepted publickey for myuser from
ip_address
port 51150 ssh2
That entry corresponds with my ssh-key-based login event. SSH is listening to default port - 22.
What is the role of logged port 51150 and does it mean I cannot use restrictive iptables settings that blocks all traffic incoming to ports other than ones that I have previously specified (like 20,21,25,80,443,143...)
The port number shown is the ephemeral client-side port number, corresponding to the source port as seen by the SSH server. Server-side, all ssh connections are to port 22.
Here's me
ssh
ing into my colo'ed server, and confirming the port listed in the relevantsyslog
file:And here's the output from the client showing the connection:
As you can see, the port number server-side is 22, as expected. It is the client-side port number that is 58212. Miloshio, since most
iptables
rules to permit access to services look something likethey are unaffected by the change in source-port number from client to client, as they only care about destination port number. Only if you were to write a rule like
would it need changing for each new client - which is why you'd have to be insane to do that, and no-one does.