Skip to main content

How can I specific local port when establish ssh connection? [Resolved]

I have two servers hosted in IDC. I can only use these port 20/21/22/23/3389/33101-33109 to establish connection between two server. The IDC network device will block any other package which source port or destination port not in 20/21/22/23/80/3389/33101-33109. But the source port of ssh is random. There is wild known that using command

ssh username@server -p remote_port

can easily specific remote port. So is there a parament or some way can specific local port so I can using maybe port 33101 to eastablish ssh connection?
My network topo just like this: enter image description here


Question Credit: fajin yu
Question Reference
Asked June 25, 2019
Tags: ssh
Posted Under: Unix Linux
42 views
1 Answers

you can not specify the source port for ssh client.

but you can use nc as a proxy, like this:

ssh -p 33101 -o 'ProxyCommand nc -p 33101 %h %p' $SERVER_2

refer:

https://serverfault.com/questions/920007/how-can-i-set-the-source-port-for-ssh-on-unbuntu-server


credit: PapEr
Answered June 25, 2019
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA