Solved

Specify outbound port with ssh?

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Network Design for the New Building 25 109
OpenView NNM: Global Manager to Regional Manager connection fails 7 56
Windows SFTP / SSH 6 81
wipe a usb using python 5 29
Secure Shell (SSH) is a network protocol for secure data communication, mainly used to administer remote Unix / Linux servers via command line. But it also allows the user to open a secure tunnel between a client and a server where he can send any k…
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
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…

910 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

23 Experts available now in Live!

Get 1:1 Help Now