1
votes

I have an ec2 box, it is an ubuntu 18.04 OS. I can using "ssh -i {pemfile} ubuntu@{ip address}" also "ssh -i {pemfile} ubuntu@{ip-ipaddress.us-east-2.compute.internal}" from another EC2 box. Now I wanted to change the hostname and use it in ssh. I followed some of linux and AWS articles AWS Article and changed /etc/hostname and /etc/hosts file. Can not use route 53 DNS entry as per requirement.

/etc/hosts = 10.0.1.190 dev-host.example.trade
/etc/hostname = dev-host.example.trade

Getting below error "ssh -i {pemfile} [email protected]" ssh: Could not resolve hostname dev-host.example.trade: Name or service not known.

2
Are you attempting to SSH from the server you made these changes on? - Chris Williams
@ChrisWilliams No its from another server - Jaishree Mishra

2 Answers

1
votes

As you’ve made the changes on the server only these will only be resolvable on that host (otherwise anyone could use any domain).

There are a few options you can take if you want to use a custom domain name.

The obvious one is you can use a domain you control, this will allow it to resolve across any hosts that are able to resolve your public DNS. If you don’t own a domain you can purchase one through a registrar (such as Route 53).

The second option is to look at using Route 53 private hosted zones. By attaching to your VPC you can set DNS records that resolve within your VPC. If you want these records to resolve in a hybrid network you would need to look at adding a DNS resolver.

The third option is to look at using a resource that can resolve the domain name, to do this you would either join a domain (using a service such as managed active directory or simple directory), or you could setup an EC2 host to resolve DNS. This is an expensive solution and the most complex if you’re using a hybrid architecture.

Take a look at the Centralized DNS management of hybrid cloud with Amazon Route 53 and AWS Transit Gateway post for more information about hybrid DNS

0
votes

Your local machine knows nothing about changes you've made to the EC2 configuration. Those changes are local to the EC2 instance.

One way to connect to your cloud instance via a DNS name like dev-host.example.trade is to associate an elastic IP to the EC2 instance. Elastic IPs persist even if the instance is rebooted.

Next, create a new A-type DNS record at your DNS provider pointing to the newly issued IP address.

You can now connect to the server with the DNS name.