1

I have a website, and I'd like to use it for SSH-ing. I hate having to remember my computer's IP address, so I was hoping to do something like:

ssh uname@me.example.com -p 1234

or

ssh uname@example.com/me -p 1234

or anything where I don't need to remember my IP, I just need the address. I really don't know much about networking, but I think example.com/me wouldn't work because that would be handled by the web-server (whatever GitHub pages uses), and therefore couldn't redirect to any sensible IP. But I presume I could get this to work with a subdomain me.example.com, and that would be great.

So can you use a subdomain pointed to an IP for SSH?

FYI, I currently have my domain with Google Domains.

  • Welcome to Webmasters! Don't worry too much. The long you work with technology, the more you understand. It all becomes very easy. Cheers!! – closetnoc Sep 22 at 14:33
2

SSH can use a domain name.

ssh uname@example.com/me -p 1234 would not be correct, however, the /me may be ignored and still work.

You should not need to use ssh uname@me.example.com -p 1234. In fact, this would take some configuration changes to make work when it should not be necessary at all.

What should happen is this. If you use your domain name, it should query for an IP address and connect to your server just fine. If you previously used an IP address and your domain name currently points to that IP address, then simply using ssh uname@example.com -p 1234 should work. Your server should handle connecting to the right account space automatically for you.

The uname should match the domain name permissions. If uname is the right username for the sites domain name, you should not have any trouble. You do not say if you have more than one site. If you have just one site, you should be fine. If you have more than one, then the domain name should match the site you are connecting to and the uname should be the user for that site.

I connect to my various sites using the domain name and username all the time. This is a perfectly normal usage.

[Update] I got the following clarifying comment.

Maybe I wasn’t clear. I’m trying to SSH into my home desktop through my domain name. I don’t plan on running a webserver of the name me.example.com, I just want it to resolve to my home desktop’s IP –

Okay, this certainly changes things up a bit. I am going to make some assumptions.

I do not like using public sub-domains for internal IP addresses. I assume you are using a private IP address in one of the following ranges; 10.0.0.0 – 10.255.255.255, 172.16.0.0 – 172.31.255.255, 192.168.0.0 – 192.168.255.255. Specifying a private IP address for a domain or sub-domain can be a security risk if made available publicly. For this reason, I do not recommend using your DNS or host provider for this.

However, there is something you can do.

You can use your local hosts file to define the sub-domain name so that it remains private. You do not say if you are using Windows or Linux.

The Windows hosts file can be found at %SystemRoot%\System32\drivers\etc\host.

The Linux hosts file can be found at /etc/hosts. In this case, hosts is a file. You would cd to /etc/ and then edit the hosts file.

cd /etc/
vi hosts

The file format is simple. For example,

me.example.com 192.168.0.2

You would use the IP address you want to connect to. Sorry. You will have to look it up one more time.

Keep in mind that the hosts file is specific to the computer you are using. In other words, if you are connecting from a laptop to your desktop and you edit the hosts file on your laptop, then me.example.com as defined in your hosts file only works for the laptop. You will need to repeat editing the host files for other computers you want to be able to use me.example.com.

This should allow you connect using the command line above for each computer you edit the hosts file for.

  • Maybe I wasn’t clear. I’m trying to SSH into my home desktop through my domain name. I don’t plan on running a webserver of the name me.example.com, I just want it to resolve to my home desktop’s IP – Enrico Borba Sep 22 at 14:49
  • I think I was confused. I don't know. Either way, I did get it to work. I just made a synthetic record subdomain forward of me.example.com to xxx.xxx.xxx.xxx (my computer's IP), and it resolves just fine now. – Enrico Borba Sep 22 at 14:58
  • I added more to the answer for the future. Cheers!! I am glad you got it to work. – closetnoc Sep 22 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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