zoukankan      html  css  js  c++  java
  • linux-解决/usr/bin/which: no ssh-copy-id in 和ssh: Could not resolve hostname问题

    使用yum install openssh-clients  安装命令

    有的系统没有此命令 有的系统缺省 就包含这一条命令!

    但是我的测试机没有发现此命令 只能这样安装!

    这时有报错了

    1
    2
    [root@ceshi .ssh]# ssh-copy-id -i ./id_rsa root@192.168.0.20
    ssh: Could not resolve hostname ./id_rsa: Name or service not known

    这是因为没有解析主机名

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    [root@puttet ~]# hostname
    abc
    [root@ceshi .ssh]# vi /etc/hosts
    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    192.168.0.19 ceshi
    192.168.0.20 abc
    [root@ceshi .ssh]# ping abc
    PING abc (192.168.0.20) 56(84) bytes of data.
    64 bytes from abc (192.168.0.20): icmp_seq=1 ttl=64 time=0.322 ms
    64 bytes from abc (192.168.0.20): icmp_seq=2 ttl=64 time=0.270 ms
    ^C
    --- abc ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1300ms
    rtt min/avg/max/mdev = 0.270/0.296/0.322/0.026 ms

     

    这样就可以了

    1
    2
    3
    4
    5
    6
    7
    8
    9
    [root@ceshi .ssh]# ssh-copy-id -i ./id_rsa.pub  root@192.168.0.20
    The authenticity of host '192.168.0.20 (192.168.0.20)' can't be established.
    RSA key fingerprint is 7b:a4:ae:42:50:8b:27:82:1c:dc:66:a9:5a:cb:67:a2.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.0.20' (RSA) to the list of known hosts.
    root@192.168.0.20's password:
    Now try logging into the machine, with "ssh 'root@192.168.0.20'", and check in:
      .ssh/authorized_keys
    to make sure we haven't added extra keys that you weren't expecting.

    ok 可以使用了!

    1
    [root@puttet ~]# cd .ssh/authorized_keys
  • 相关阅读:
    C 语言中的 fgets()
    C++ 中的 C_str() 函数用法
    Ubuntu 下使用 sshfs 挂载远程目录到本地
    VirtualBox 下主机与虚拟机以及虚拟机之间互通信配置
    转:sudo 的常见用法和参数选项
    “a++” 与 “++a” 的区别
    Linux 下运行 C++ 程序出现 “段错误(核心已转储)”
    vector容器中添加和删除元素
    NCCloud 指令示例
    c++ find函数用法
  • 原文地址:https://www.cnblogs.com/drizzle-xu/p/9155268.html
Copyright © 2011-2022 走看看