/usr/bin/which: no ssh-copy-id in 和ssh: Could not resolve hostname

简介:
1
2
3
4
[root@ceshi . ssh ] # which ssh-copy-id
/usr/bin/which : no  ssh -copy- id  in  ( /usr/local/sbin : /usr/local/bin : /sbin : /bin : /usr/sbin : /usr/bin : /root/bin )
[root@ceshi ~] # ssh-copy-id-i.ssh/id_rsa root@192.168.0.20
- bash ssh -copy- id -i. ssh /id_rsa : 没有那个文件或目录

使用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 可以使用了!:




本文转自 cs312779641 51CTO博客,原文链接:http://blog.51cto.com/chenhao6/1347626
1
[root@puttet ~] # cd .ssh/authorized_keys

相关文章
|
1月前
|
存储 网络安全
Curl error (60): SSL peer certificate or SSH remote key was not OK for https://update.cs2c.com.cn/NS/V10/V10SP2/os/adv/lic/base/x86_64/repodata/repomd.xml [SSL: no alternative certificate subject name matches target host name 'update.cs2c.com.cn']
【10月更文挑战第30天】在尝试从麒麟软件仓库(ks10-adv-os)下载元数据时,遇到 SSL 证书验证问题。错误提示为:`Curl error (60): SSL peer certificate or SSH remote key was not OK`。可能原因包括证书不被信任、证书与域名不匹配或网络问题。解决方法包括检查网络连接、导入 SSL 证书、禁用 SSL 证书验证(不推荐)、联系仓库管理员、检查系统时间和尝试其他镜像。
283 1
|
6月前
|
网络安全
ssh: Could not resolve hostname centos02: Temporary failure in name resolution
ssh: Could not resolve hostname centos02: Temporary failure in name resolution
551 0
|
弹性计算 网络安全
ECS由于/usr/lib/systemd/system/sshd.service配置错误导致ssh无法启动
ECS由于/usr/lib/systemd/system/sshd.service配置错误导致ssh无法启动
|
网络安全 开发工具 git
错误解决办法:exec /usr/lib/ssh/ssh-askpass : No such file or directory error.
错误解决办法:exec /usr/lib/ssh/ssh-askpass : No such file or directory error.
298 0
|
网络安全
guard.: ssh: Could not resolve hostname guard.: Name or service not known to: ss
hadoop 安装的时候,报错信息   guard.: ssh: Could not resolve hostname guard.: Name or service not known to: ssh: Could not resolve hostname to: Name or...
1444 0
|
网络安全 数据安全/隐私保护
|
1月前
|
监控 Ubuntu Linux
使用VSCode通过SSH远程登录阿里云Linux服务器异常崩溃
通过 VSCode 的 Remote - SSH 插件远程连接阿里云 Ubuntu 22 服务器时,会因高 CPU 使用率导致连接断开。经排查发现,VSCode 连接根目录 ".." 时会频繁调用"rg"(ripgrep)进行文件搜索,导致 CPU 负载过高。解决方法是将连接目录改为"root"(或其他具体的路径),避免不必要的文件检索,从而恢复正常连接。
|
6月前
|
安全 Linux Shell
Linux中SSH命令介绍
Linux中SSH命令介绍
169 2
|
4月前
|
监控 安全 Ubuntu
在Linux中,如何进行SSH服务配置?
在Linux中,如何进行SSH服务配置?