After typing sudo su command, on SSH we can receive the error output sudo: unable to resolve host on HP Cloud Instance. Here is How To Fix. First you need to set Ingress-Egress Policies rightly on HP Helion Public Cloud and set the Router and Subnet rightly to properly do SSH. If you can do SSH with the Private Key and command like
ssh -i YOUR-KEY.pem ubuntu@YOUR-IP, then your setup is fully right from the point of SSH. You need not to fight with the security settings.
sudo: unable to resolve host HP Cloud Instance Fix – Basics
There is a file on your Linux instance on HP Helion Cloud – it called the Hosts file. While spinning up the instance, OpenStack Neutron, one line is not injected on the build. That is why you get the error. We are describing the method for Ubuntu (14.04 LTS), you should double check the official documentation for Other Linux Distros for the location of this Hosts file.
We are assuming that,
abhishek-ghosh is your instance’s name. In that case, if you open this file
/etc/hostname you’ll notice the name. If you change it to, for example;
dr-abhishek-ghosh, for dedicated and non-OpenStack non-Cloud instances, a simple reboot after editing will change the instance’s name. However, you should not change it on HP Cloud as you might difficult to control. This was injected while you created the instance. This file need not to be Edited to resolve the error sudo: unable to resolve host.
Second file is
/etc/hosts. It will have content like this :
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
We will edit this file in one command in very funny way.
Image used is from
www.tecmint.com for decorating this article.
sudo: unable to resolve host HP Cloud Instance Fix – Steps
sudo su - to get root privilege. You will get error. No worries. This will be the last time to get the error.
Simply run this command in SSH then :
echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /etc/hosts
Essentially, we have echoed the real hostname (
abhishek-ghosh was the example), the command has written one line on
/etc/hosts file. It is for Ubuntu, if your Linux distort has different location of Hosts file, changing the last part will work :
echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /path/to/hosts
# /path/to/hosts is an existing path
It has added something like this :
/etc/hosts file with instance name of
abhishek-ghosh as example. Although we have asked to check your disto, it is likely that your distro will have the same path too –
/etc/hosts. You can run
whereis hosts or
locate hosts to find on SSH. Ting.