Solved

Specify outbound port with ssh?

Posted on 2009-07-14
2
843 Views
Last Modified: 2012-06-21
I am ssh'ing to a remote server, which is listening on the standard port 22, using a no-frills "ssh user@hostname.com" command to connect.

I would like to specify the outbound port my system uses to connect.  By default it gets a normal system-assigned port like 55129, etc.  Is there a way to tell ssh to use a specific outbound port?

Reading the man pages and googling, I found the -R and -L options for forwarding, which are useful for tunnelling.  I can specify my bind address with "-b <address>" and the remote port to connect to with "-p <port>".  

But I can't see where to specify the outgoing port I want ssh to use.  I want to do this so I specify on the remote system to only allow incoming connections from specific ports on the clients.

Is this possible?

Thanks,
Ted
0
Comment
Question by:mactfines
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 24848759
use the -p portno option
0
 
LVL 14

Accepted Solution

by:
flob9 earned 500 total points
ID: 24848789
Under linux :

#set custom port range
echo "55129 61000" > /proc/sys/net/ipv4/ip_local_port_range

#connect
ssh myhost.com

#restore port range
echo "32768   61000" > /proc/sys/net/ipv4/ip_local_port_range

More information here : http://www.ice.mtu.edu/~jamyles/docs/ncftpd/doc/misc/ephemeral_ports.html
0

Featured Post

ClickHouse in a General Analytical Workload

We have mentioned ClickHouse in some recent posts, where it showed excellent results.

In this article on Experts Exchange, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
Fine Tune your automatic Updates for Ubuntu / Debian
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question