![SSH 问题](https://linux22.com/image/1537143/SSH%20%E9%97%AE%E9%A2%98.png)
当我尝试远程访问(通过 ssh)时出现以下错误。
ssh: Could not resolve hostname : Name or service not known
问题:
[daniel@daniel_pc ~]$ ssh [email protected]
ssh: Could not resolve hostname : Name or service not known
但这仅当我尝试使用 ssh 进行远程访问时才会发生,例如,如果我尝试 ping 它,我可以正常获得它,如下例所示。
[daniel@daniel_pc ~]$ ping 192.168.0.212
PING 192.168.0.212 (192.168.0.212) 56(84) bytes of data.
64 bytes from 192.168.0.212: icmp_seq=1 ttl=63 time=1.08 ms
64 bytes from 192.168.0.212: icmp_seq=2 ttl=63 time=8.39 ms
64 bytes from 192.168.0.212: icmp_seq=3 ttl=63 time=0.620 ms
64 bytes from 192.168.0.212: icmp_seq=4 ttl=63 time=1.09 ms
^C
--- 192.168.0.212 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3033ms
rtt min/avg/max/mdev = 0.620/2.799/8.396/3.237 ms
在我将“config”文件添加到“/home/daniel/.ssh/”并将我想要的主机信息输入“/etc/hosts”后,问题开始出现。
问题发生后,我删除了“配置”并删除了“主机”中的信息,但问题仍然存在。
值得记住的是,当我尝试通过 root 用户访问时,我通常会访问访问权限。
[daniel@daniel_pc ~]$ su
Senha:
[root@daniel_pc daniel]# ssh 192.168.0.212
Last login: Wed Jul 26 10:44:46 2017 from 192.168.0.99
信息:Fedora 25
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-696.1.1.el6.x86_64 #1 SMP Tue Apr 11 17:13:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /proc/version
Linux version 2.6.32-696.1.1.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Tue Apr 11 17:13:24 UTC 2017
[daniel@daniel_pc .ssh]$ ssh -vv [email protected]
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /home/daniel/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 2: include /etc/crypto-policies/back-ends/openssh.config matched no files
debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *
debug2: resolving "" port 22
ssh: Could not resolve hostname : Name or service not known