Solved

Specify outbound port with ssh?

Posted on 2009-07-14
2
829 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
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

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 …
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

820 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