Ubuntu ssh: Could not resolve hostname myserver: Name or service not known

Rajeev

I'm trying login from local machine to aws ubuntu server but I'm unable to login on aws ubuntu server with hostname.

ssh -i key.pem ubuntu@myserver

Getting below error:

ssh: Could not resolve hostname myserver: Name or service not known

I'm able to login with public IP of this server without any issue.

for example:

ssh -i key.pem [email protected]

I have changed the hostname with below commands.

1) sudo vim /etc/hosts

2) 127.0.0.1 localhost myserver

3) sudo hostnamectl set-hostname myserver

used the below link to change hostname.

https://aws.amazon.com/premiumsupport/knowledge-center/linux-static-hostname/

How can login on aws ubuntu server with hostname instead of IP address?

Please help me.

Thomas

The problem is, that your local computer do not know myserver. So you have several option:

1.) You can edit your local /etc/hosts and set there the public IP to myserver, but than you need to do it on all computer which should access myserver

2.) If you are own a domain, you can set the public IP of your server to myserver.mydomain.com in your DNS configuration.

3.) You can also set myserver in .ssh/config

Host myserver
         Hostname ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com
         IdentityFile /Users/TNowak/.ssh/id_rsa

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Unable to ssh into Ubuntu 12.04 LTS [could not resolve hostname (hostname): Name or service not known

ssh: Could not resolve hostname server: Name or service not known

ssh: Could not resolve hostname git: Name or service not known fatal: Could not read from remote repository

ssh: Could not resolve hostname ubuntu: Temporary failure in name resolution

ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known

OSX: ssh: Could not resolve hostname: nodename nor servname provided, or not known

hostname: Name or service not known

SSH host: Could not resolve hostname

SSH config explanation: Could not resolve hostname: nodename nor servname provided, or not known

Fedora 28 - ssh - Could not resolve hostname

ssh: Could not resolve hostname – High Sierra

Yarn: unable to clone private github repo. ssh: Could not resolve hostname github: nodename nor servname provided, or not known

SOCKS5 proxy with username and password – ssh: could not resolve hostname, temporary failure in name resolution

curl: (6) Could not resolve host: google.com; Name or service not known

sudo: unable to resolve host slave-node: Name or service not known when need to install skaffold on ubuntu 20

"Could not resolve hostname" Ansible

Kubernetes - resolve hostname of a service

Doing ssh tunnel with Python script. Error: "Could not resolve hostname when trying to open ssh tunnel"

rabbtimqadmin - Could not connect: [Errno -2] Name or service not known

scp can't access SSH alias: Name or service not known

Error “ssh: Name or service not known” while using mpirun in Linux

Git:Adding error adding a second github account "ssh: Could not resolve hostname github-secondUser"

Using yo angular-fullstack:openshift gives error 'ssh: Could not resolve hostname'

ssh: Could not resolve hostname sama5d27-som1-ek-sd:

ssh could not resolve host name for ec2 instance

JWTRefreshTokenBundle: Name or service not known

ftp: Name or Service not known

Ping : Name or service not known

Creating engine in SQLAlchemy: could not translate host name to address: Name or service not known

TOP Ranking

HotTag

Archive