/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

相关文章
|
网络安全 开发工具 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.
212 0
|
弹性计算 网络安全
ECS由于/usr/lib/systemd/system/sshd.service配置错误导致ssh无法启动
ECS由于/usr/lib/systemd/system/sshd.service配置错误导致ssh无法启动
|
网络安全 数据安全/隐私保护
|
1月前
|
安全 Linux Shell
Linux SSH(Secure Shell)服务
Linux SSH提供安全网络协议,使用公钥加密技术确保远程服务传输安全。OpenSSH是实现SSH服务的免费开源工具,允许用户加密连接远程登录Linux服务器执行任务。SSH比Telnet更安全,防止数据被截获。SSH还支持端口转发和隧道,广泛应用于系统管理和网络维护,是安全远程访问服务器的重要工具。
26 1
|
4月前
|
Linux 网络安全
Linux命令(124)之ssh
Linux命令(124)之ssh
35 2
|
2月前
|
安全 Shell Linux
【Shell 命令集合 文件管理】Linux ssh 远程主机之间复制文件 scp 命令使用教程
【Shell 命令集合 文件管理】Linux ssh 远程主机之间复制文件 scp 命令使用教程
45 0
|
19天前
|
Linux 网络安全 数据安全/隐私保护
SSH工具连接远程服务器或者本地Linux系统
SSH工具连接远程服务器或者本地Linux系统
19 0
|
7天前
|
存储 安全 Linux
|
13天前
|
监控 安全 Linux
【专栏】Linux SSH 的安全对于远程管理至关重要,这几个小妙招安排上!
【4月更文挑战第28天】在数字化时代,Linux SSH 的安全对于远程管理至关重要。增强 SSH 安全包括:使用强密码,调整 SSH 配置文件,尤其是端口号和认证方式;采用密钥认证代替密码;限制登录用户,禁止密码登录;使用防火墙限制访问;定期更新系统和软件。此外,通过日志监控、入侵检测系统及及时应对攻击来提升安全监控。保持对安全知识的学习和更新,结合最佳实践,是保障 SSH 安全的关键。记得安全是个持续过程,时刻保持警惕!