Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .