1

I want to run my sshd server on multiple ports but different domains.

The server should be reachable as following:

ssh -p 12345     example.com
ssh -p 22    git.example.com

I tried to modify /etc/ssh/sshd_config like this:

Port 12345
ListenAddress 0.0.0.0
ListenAddress git.example.com

But that's not working.

fechnert
  • 133
  • 9
  • 2
    The ssh protocol has no notion of domain names. Only IP addresses matter. Do you have multiple IP addresses assigned to that host? – kasperd Aug 20 '14 at 13:55
  • Yep i have as shown above. one without and one with prefix – fechnert Aug 20 '14 at 14:31
  • 2
    No, you haven't. You have mentioned only domain names. They don't matter. All that matters is the IP address. There is no information about IP addresses in your question. You do know the difference between a domain name and an IP address? – kasperd Aug 20 '14 at 14:34
  • Sorry i mis-readed the question, the server only have one IP address – fechnert Aug 20 '14 at 14:36
  • 1
    So you want sshd to listen on two different ports on one IP address? – kasperd Aug 20 '14 at 16:07

1 Answers1

1

https://superuser.com/questions/597660/sshd-service-listening-on-multiple-ports

You could also do something with iptables to shuffle the ports around.

ssh does not care so much about domains. It just listens on an ip:port combination. Its up to you to make the domains point at the right ip.

Russ Huguley
  • 156
  • 3
  • thanks, both domains point to the right ip but i want to filter that the domain wihtout prefix needs port 12345 and the domain with prefix need no port – fechnert Aug 20 '14 at 14:30
  • @Tim That's impossible. How would the server know whether the domain was specified with or without the prefix? That's like trying to tell if someone calling you looked up your phone number in print or online when the listed number is the same in both cases. All you know is that your phone is ringing. – David Schwartz Aug 20 '14 at 15:19
  • @DavidSchwartz - Thanks for this explanation. I get the point and can feel how dump my question is – fechnert Aug 21 '14 at 14:44
  • It is not so dumb to think that way. Apache and other webservers work this way with virtualhosts. So if you were thinking ssh would work the same then it is not so dumb. – Russ Huguley Aug 21 '14 at 15:40