Solved

Specify outbound port with ssh?

Posted on 2009-07-14
2
824 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
2 Comments
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
use the -p portno option
0
 
LVL 14

Accepted Solution

by:
flob9 earned 500 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello EE, Today we will learn how to send all your network traffic through Tor which is useful to get around censorship and being tracked all together to a certain degree. This article assumes you will be using Linux, have a minimal knowledge of …
David Varnum recently wrote up his impressions of PRTG, based on a presentation by my colleague Christian at Tech Field Day at VMworld in Barcelona. Thanks David, for your detailed and honest evaluation!
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now