Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Trying ssh -p 51685 seems to change the port that I'm trying to connect to, not my outgoing port.

As does editing ssh_config.

I want to change my outgoing port from 22 (which is blocked) to 51685.

Any ideas?

share|improve this question
Maybe I'm missing something obvious, but what is wrong with the two approaches you list yourself? – Michael Kjörling Feb 25 '11 at 13:30
@Michael: the two methods he lists change the destination port, not the source port. – David Spillett Feb 25 '11 at 14:01
Odds are, the corporate firewall you're trying to circumvent is doing packet inspection and is blocking traffic DESTINED for 22. See Dave's answer below. – peelman Feb 25 '11 at 16:01

Outgoing connections do not use fixed port assignments, they choose an available port number, usually higher than 1024. More to the point, unless you are running as root (the admin user account, which is disabled by default on OSX), you cannot open an outgoing connection on port 22 because only root is allowed to open any ports below 1024. Therefore, if you're running ssh and are not root at the time, you're definitively not using port 22 for outgoing connections.

Whatever issue you're having, you have incorrectly identified its cause.

share|improve this answer

Are you sure it is the source port that is being filtered? Clients usually use an arbitrary source port (between 1024 and 65535) not the protocol's assigned port, and if your connection passes through any NAT arrangements on the way between you and the server (or the device that is doing the blocking) the original source port will be "lost" anyway so source port based filtering isn't usually very useful anyway.

For instance I've just made a fwe connections using PuTTY and OpenSSH to one of my servers, and wireshark tells me that the source ports for the connections where 6525, 6535, 6560 and 6562.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .