LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-27-2007, 02:25 PM   #1
nickj6282
Member
 
Registered: Mar 2006
Location: Fond du Lac, Wisconsin, USA
Distribution: Debian
Posts: 51

Rep: Reputation: 15
Run SSH on different ports?


Hi all,

I'm trying to figure out if there's a way to run SSH on different ports based on the IP address. I've got a linux box acting as my router. I want to be able to access SSH on the external interface via a different port than the internal interface, which will use standard port 22. Can anyone point me in the right direction?

Thanks,
-Nick
 
Old 04-27-2007, 02:47 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
nothing to do with ssh really.. just use port forwarding to a different port within the router. anything that hits my adsl router on port 2222 goes through to an internal machine on 22.
 
Old 04-27-2007, 06:11 PM   #3
nickj6282
Member
 
Registered: Mar 2006
Location: Fond du Lac, Wisconsin, USA
Distribution: Debian
Posts: 51

Original Poster
Rep: Reputation: 15
Ok, the linux box that this is on IS the router, so how would I go about forwarding a port from itself to itself?

This machine has an interface on the outside, we'll say it's 10.0.0.1, and another on the inside, 192.168.1.1

What I want is SSH listening on 10.0.0.1:1234 and 192.168.1.1:22. Is there a way to configure it like this?

Thanks,
-Nick
 
Old 04-27-2007, 08:01 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Have a look at man sshd_config. It sounds like you want the ListenAddress option. From the man page:
Code:
             Specifies the local addresses sshd(8) should listen on.  The following forms may be used:

                   ListenAddress host|IPv4_addr|IPv6_addr
                   ListenAddress host|IPv4_addr:port
                   ListenAddress [host|IPv6_addr]:port

             If port is not specified, sshd will listen on the address and all prior Port options specified.  The
             default is to listen on all local addresses.  Multiple ListenAddress options are permitted.  Addition-
             ally, any Port options must precede this option for non-port qualified addresses.
You'd have:
Code:
ListenAddress 10.0.0.1:1234
ListenAddress 192.168.1.1:22
 
Old 04-28-2007, 11:56 AM   #5
hollywoodb
Member
 
Registered: Aug 2003
Location: Minnesota, U.S.A.
Distribution: Debian, openSUSE
Posts: 400

Rep: Reputation: 30
On my setup:

Router
-> Laptop (sshd listening on port X)
-> Desktop (sshd listening on port Y)

I have the router set to forward port X to the laptop and port Y to the desktop. Then when I ssh from some remote location I can pick my machine by port.

In /etc/ssh/sshd_config you can set the "Port" line without messing with the ListenAddress or anything fancy.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH working on different ports oxide Linux - Security 9 10-09-2004 10:06 AM
SSH listen on two ports Buto Slackware 1 10-02-2004 01:15 PM
ssh on two ports mazzo Linux - Security 8 09-25-2004 10:05 PM
SSH and ports zowey Linux - Networking 4 07-19-2004 06:31 AM
ssh ports phishintrip Linux - Networking 2 07-02-2003 02:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration