Ssh:could not resolve hostname devsrv:name or service not known

Source: Internet
Author: User
Tags ssh

Ubuntu down SCP Error: ssh:could not resolve hostname devsrv:name or service not known

Workaround:

You need to add the Devsrv IP to the filename/etc/hosts.


Additional

/etc/hosts file function:

1. About/etc/hosts, host name and IP configuration file

Hosts-the static table lookup for host name (host name query static tables)

Linux/etc/hosts is a file that configures the IP address and its corresponding hostname, where you can record the IP and its corresponding host name of the machine or other host. Different versions of Linux, this configuration file may also be different. For example, the corresponding file in Debian is/etc/hostname.

2. Configuration file

This file can configure the host IP and the corresponding host name, for the server type of Linux system its role is not negligible. On the LAN or Internet, each host has an IP address, which separates each host and can communicate according to IP. But the IP address is not convenient memory, so there is a domain name. In a local area network, each machine has a host name that is used to differentiate between hosts for easy access.

The configuration file for the Linux hostname is/etc/hosts; This file tells the host which domain names correspond to those IP, which IP is the host name:

such as the definition in a file

192.168.1.100 linumu100 test100

Assuming that 192.168.1.100 is a Web server, entering http://linumu100 or http://test100 in a Web page opens 192.168.1.100 's Web page.

Typically this file first records the IP and host name of the computer:

127.0.0.1 localhost.localdomain localhost

3. configuration file Format description

General/etc/hosts content generally has the following similar content:

127.0.0.1 localhost.localdomain localhost

192.168.1.100 linmu100.com linmu100

192.168.1.120 Ftpserver ftp120

In general the Hosts file for each behavior of a host, each line consists of three parts, each part by a space separated. The lines at the beginning of the # number are described and are not interpreted by the system.

The first part: Network IP address;

Part II: Host name or domain name;

Part III: host name alias;

Of course, each line can also be two parts, that is, the host IP address and host name, such as 192.168.1.100 linmu100.

Here you can explain a bit about the difference between host name (hostname) and domain name (domain): Host name is usually used in LAN, through Hosts file, host name is resolved to the corresponding IP; Domain names are usually used on the internet, However, if the computer does not want to use the Internet domain name resolution, then you can change the Hosts file, add their own domain name resolution.

4./hosts files can help solve problems

4.1 Remote login to the Linux host too slow problem

Sometimes the client wants to log on to a Linux host, but each login to enter the password will wait a long time to enter, this is because the Linux host in the return of information needs to resolve IP, if the hosts in the Linux host file in advance to join the client's IP address, At this point, remote login to Linux from the client will become very fast.

Note: The remote logins mentioned here are not only ssh, but may also be MySQL remote logins, or file-sharing queries.

4.2 Dual-Machine interconnection

When two hosts are only two-machine interconnection, when both hosts need to set their own IP, at the same time in each other's Hosts file to add their own IP and host name.

5. Hostname modification tool hostname;

In fact, the host name of the modification also has a dedicated tool, is hostname

Hostname-show or set the system ' s host name

Display host Name:

# hostname

linmu100

The host name of this host is linmu100, and no parameter is used to display the host name of the current host;

Set host name temporarily:

# hostname test100

# hostname Note: Display host name

test100

Setting the hostname by the hostname tool is temporary and will not exist the next time the system is restarted;

Show host IP:

# hostname-i

192.168.1.100

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.