Thursday 31 May 2018

redirection - Hostmonster Subdomain redirected to home server IP: How to ssh into home server using subdomain


I setup a home server to play with. Instead of remembering the IP address, I created a subdomain on my hostmonster personal website (http://subdomain.domainname.com) and redirected it to point at my server at home.


On my router firewall at home, I forwarded port 80 and 22 to allow web and ssh to get through to that server.


It seems, however, that my webhost forwards the port 80 requests, but does not forward ssh requests. I came to that conclusion after noticing the following:


When I access http://subdomain.domain.com I successfully see the web pages hosted on my home server. However, when I ssh into homeusername@subdomain.domain.com I cannot authenticate. ssh'ing into homeusername@homeIP works fine.


I also found that ssh'ing into webloginusername@subdomain.domain.com will ssh successfully into my web account.


Does anyone know how I can setup that kind of 'ssh forwarding' ?


Thanks in advance,



Answer



You need to go into your domain's name server, and create an A record for your subdomain that points at your home IP. If you don't have a static IP at home, then you'll need to setup a dynamic DNS. There are many Dynamic DNS providers on Google; find one you like.


The key part of your question is that you "redirected" your subdomain to point at your server at home. I assume that you used something like the HTTP refresh header. When you try to reach your home server through the redirect, this is how the flow works:



  1. You send a request on port 80

  2. The Hostmonster server receives the request on port 80

  3. The apache server sees the redirect, and forwards to the redirect's port 80

  4. Your request reaches your home router on port 80

  5. Your request reaches your home server on port 80


Now here's what happens when you try to ssh into your home server:



  1. You send a request on port 22

  2. The Hostmonster server recieves the request on port 22

  3. The Hostmonster sees that your user doesn't exist on the server; access denied


The difference is that on port 80, apache sees the redirect. On port 22, sshd doesn't know about a redirect and believes you're trying to ssh into the Hostmonster server.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...