log into SSH server using a subdomain by adding an "A Record"

3

I SSH into a series of static IP addresses, but it's easy to forget which one is which. I'd like to replace the static IP addresses with a subdomain of a domain I own.

I.e.,

55.55.555.55 --> box1.example.com

55.55.555.56 --> box2.example.com

55.55.555.57 --> box3.example.com

I tried setting the "A Record" for my subdomain. There is now an "A Record" for box1.example.com that points to 55.55.555.55. The problem is that when I try to SSH into box1.example.com, I don't think it's pointing to 55.55.555.55, but still points to some random box where the website for my domain (example.com) is being hosted. The subdomain doesn't appear to be redirecting to the static IP address I entered when I attempt to SSH. Any help would be appreciated. When I use "dig box1.example.com" I see an A record for the web hosts IP address and the one I entered is nowhere to be found

user2815185

Posted 2013-09-25T15:16:21.903

Reputation: 31

How did you add the A record? What format does it have? If you've set it up through a web interface of your provider, it's possible that they haven't merged your change into the actual zone file yet. – Der Hochstapler – 2013-09-25T15:17:50.647

I use NTC hosting and the interface for adding a record is really simple, so I doubt that I did that wrong. NTC hosting has a control panel that allows one to specify the IP address for the A record and the TTL. I left the default TTL and entered the IP address I want to redirect to as the A Record Value. This was done over 24 hours ago, so I doubt it's just a time issue unless they are really that slow at propagating record changes. – user2815185 – 2013-09-25T17:20:35.020

Is the domain name pointed at the NTC name server(s)? If not, then making changes at NTC is not going to change what is on the name serves the domain is pointed at. – Justin Pearce – 2013-09-25T18:49:40.880

My subdomain shows an A record pointed at 198.23.53.106, which is for LiquidNet and NTC hosting is listed as one of their clients. – user2815185 – 2013-09-25T19:50:04.450

If your domain has a wildcard listing in DNS then all sub domains will resolve to that address and any lookups will get cached for a period of time. Those cached entries need to expire and be cleared before any DNS lookups will see the new A Record entries. – Brian – 2013-09-25T20:58:39.550

I found out why this was happening. Apparently, I had "parked" the domain. Turns out that A record entries or ignored for a parked domain. Thanks for your help. Glad this was resolved and that I don't have to memorize an endless stream of IP addresses. – user2815185 – 2013-09-26T21:33:04.860

Answers

2

On your client machine, create ~/.ssh/config

host box1
hostname 55.55.55.55
user bob

host box2
hostname 55.55.55.56
user bob

Then "ssh box1", "ssh box2" do the expected things. You can also set other options like port 2222, ForwardX11 yes, ForwardAgent yes etc.

Brian Candler

Posted 2013-09-25T15:16:21.903

Reputation: 21

0

It sounds like the domain is already configured on the DNS server (possibly with a wild card). I don't believe there's any "good" way to fix this (at the network level).

An alternative to making changes to DNS would be to set up aliases on the command line. In .bashrc (or on some systems, .bash_aliases), add the following:

alias box1 = 'ssh bob@55.55.555.55'
alias box2 = 'ssh bob@55.55.555.56'

With the above, once you've logged out and back in (or just run "bash" again), typing in "box1" (without the quotes) will run the command in the quotes. If you've configured ssh-agent and are using key-based authentication, you'll be able to connect to multiple systems without having to retype your SSH password(s).

Hope this helps.

joat

Posted 2013-09-25T15:16:21.903

Reputation: 466