Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Platforms- sudo: unable to resolve host [closed]

I use linux for my cloud based servers on Amazon-EC2 and openstack. When trying to run:

sudo chhown ubuntu somepath

I get this error every once in a while:

sudo: unable to resolve host

Most answers to this question on the internet are to edit the /etc/hosts file.

However, I deploy my servers automatically. besides that, I am not logging on using "localhost", but rather my AWS public DNS:

ssh -i mykey.pem [email protected]

So I cannot just trivially insert localhost, not to mention that my IP can change after I reset my machine. (Don't want to "waste" my precious floating IPs for every server)

Also, I deploy tens of servers at a time, so I cannot afford the manual step of editing a text file. Is there an automated fix for this issue? Recently I've started using openstack, and the issue is present there too.

like image 242
eshalev Avatar asked Jan 02 '15 11:01

eshalev


2 Answers

EC2 instances inside VPC will resolve their auto-assigned internal hostnames correctly, only if you configure the VPC correctly. You need:

DNS hostnames: yes
DNS resolution: yes

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html

like image 57
Michael - sqlbot Avatar answered Oct 06 '22 02:10

Michael - sqlbot


To resolve this problem I ran the following commands:

sudo vi /etc/hosts

Then in the hosts file that opens up add:

127.0.0.1     10.0.30.150

Obviously the 10.0.30.150 address would be the IP of the host in the warning message.

like image 33
ajtrichards Avatar answered Oct 06 '22 03:10

ajtrichards