Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to configure OpenSSH to use port 22 for LAN clients, but to use a non-standard port for all outside addresses. How would this be done?

What I have in mind is imagined to be like this:

Match Address 192.168.0.0/24
Port 22

Match Address <all others>
Port 2022

I'm not sure how to implement it in sshd_config or if it is possible.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

I would think iptables would be a better solution for this. If the system is behind a NATing router ( most common home setups ) simply forward the non-standard port to the regular port. However if the system is in a DMZ or directly connected to the internet, use iptables to redirect port 2022 to 22.

share|improve this answer
    
@Lamar--it is behind a NATing router. I will use your suggestion to forward the non-standard port to the regular port. Thanks –  Ace Paus Apr 12 '12 at 1:46
    
This is the way to go. –  stefgosselin Apr 12 '12 at 3:58

depends on your OS you can configure port filtering/forwarding to filter any outside rules for port 22 and configure alternative port to do port forwarding to your local port 22

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.