scp 及 ssh 命令出错解决

问题scp命令失效,即ssh貌似没有工作。首先看对方ssh服务是否开启,发现可以telent上
scp 及 ssh 命令出错解决_第1张图片

ssh 排错

在这里插入图片描述

[root@client ~]#rpm -qa | grep ssh      #server和clients均安装了		
openssh-clients-5.3p1-124.el6_10.i686
openssh-5.3p1-123.el6_9.i686
openssh-server-5.3p1-124.el6_10.i686
openssh-5.3p1-124.el6_10.i686
libssh2-1.4.2-3.el6_10.1.i686

进一步排查各个安装包,最终发现在openssh-clients的问题,重装后解决,同时目标机仍要解决此问题,scp才可传送文件。

[root@client ~]#yum install openssh-clients
...
Running Transaction
  Installing : openssh-clients-5.3p1-124.el6_10.i686                                                                                                                                                                                                        1/1 
  Verifying  : openssh-clients-5.3p1-124.el6_10.i686                                                                                                                                                                                                        1/1 

Installed:
  openssh-clients.i686 0:5.3p1-124.el6_10                                                                                                                                                                                                                       

Complete!

[root@client ~]#ssh --help     #现在ssh命令好使了		
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-I pkcs11] [-i identity_file]
           [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]

ssh远程成功,报错failed - POSSIBLE BREAK-IN ATTEMPT

sed -i 's/#   GSSAPIAuthentication no/GSSAPIAuthentication no/' /etc/ssh/ssh_config

在这里插入图片描述

scp 排错

scp使用的是ssh协议,这里可能将我远程登录成功界面的打印信息当做了文件传输的一部分,导致传送文件出错。

[root@client ~]#scp [email protected]:/home/tom/zero.txt ./
Red Hat Enterprise Linux Server release 6.0 (Santiago)
Kernel 2.6.32-754.35.1.el6.i686 on i686
Local IP addresses: 192.168.31.222 

[email protected]'s password: 
      May 2022      
[root@ton tom]#mv /etc/issue.net /etc/issue.net.bak				#暂时删除界面打印信息
[root@client ~]#scp [email protected]:/home/tom/zero.txt ./			#还有界面打印信息,再删除/etc/ssh/sshr脚本
[email protected]'s password: 
      May 2022      

[root@client ~]#scp [email protected]:/home/tom/zero.txt ./			#传输成功
[email protected]'s password: 	
zero.txt                                                                                                                     100%  512     0.5KB/s   00:00    
[root@client ~]#

反之可以考虑使用同步rsyncftp等其他来取代scp传送文件。

你可能感兴趣的:(Linux,ssh,scp)