SCP“失去连接”,但SSH工作正常


10

我可以通过ssh处理的服务器已经开始拒绝scp。

$ scp ~/tmp/foo user@some.example.com:~/tmp/
lost connection

随着scp -v -v我可以看到连接成功和转移看似成功,但没有文件出现在另一边。

OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/schwern/.ssh/config
debug1: /Users/schwern/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to testcurrent01.dev.liquidweb.com [10.30.152.254] port 22.
debug1: Connection established.
debug1: identity file /Users/schwern/.ssh/id_rsa type -1
debug1: identity file /Users/schwern/.ssh/id_rsa-cert type -1
debug1: identity file /Users/schwern/.ssh/id_dsa type -1
debug1: identity file /Users/schwern/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
...lots of authentication details...
debug1: Enabling compression at level 6.
debug1: Authentication succeeded (publickey).
Authenticated to user@some.example.com ([1.2.3.4]:22).
debug2: fd 5 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug2: fd 3 setting TCP_NODELAY
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug1: Sending command: scp -v -t -- ~/tmp/
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 4576, received 2520 bytes, in 0.0 seconds
Bytes per second: sent 167737.0, received 92372.6
debug1: Exit status 0
debug1: compress outgoing: raw data 135, compressed 121, factor 0.90
debug1: compress incoming: raw data 66, compressed 52, factor 0.79
lost connection

这是一台CentOS 5.9机器。

我检查过的事情...

  • 我有权写入该目录。
  • 用户有一个明智的外壳(/ bin / bash)。
  • 我试图将自己~/.ssh/config移开。
  • 从具有完全不同的操作系统的其他计算机窃取到该计算机也将失败。
  • 磁盘未满。
  • 重新启动sshd。

/ var / log / secure包含...

Apr  4 14:23:22 some sshd[12576]: Postponed publickey for user from 1.2.3.4 port 33581 ssh2
Apr  4 14:23:22 some sshd[12575]: Accepted publickey for user from 1.2.3.4 port 33581 ssh2
Apr  4 14:23:22 some sshd[12575]: pam_unix(sshd:session): session opened for user user by (uid=0)
Apr  4 14:23:22 some sshd[12575]: pam_unix(sshd:session): session closed for user user

接下来我要检查什么?


2
不是我所期望的错误,但以防万一,您的~/.bashrcor ~/.profile/etc/bash.bashrcor /etc/profile打印任何内容到STDOUT吗?bugzilla.redhat.com/show_bug.cgi?id=20527。我认为您正在使用Linux?
terdon

不。我只是平常Last login: Thu Apr 4 10:15:28 2013 from 1.2.3.4
Schwern 2013年

目标主机上任何系统日志中的任何内容?
2013年

@Flup看起来很正常。我在连接时张贴了日志中显示的内容。
Schwern 2013年

您能否strace -f -o /tmp/sshd.strace -p [pid of sshd]在服务器上启动,再试一次,然后从该文件中发布任何看起来相关的内容?
2013年

Answers:


1

有同样的问题。

如果您仅进行了最小程度的Centos安装,则仅安装opensshopenssh-server软件包,而不安装openssh-clientssudo yum install openssh-clients将解决您的问题。


我再也无法访问该机器,但这似乎是一个可能的答案。
Schwern 2014年

4

scp通过ssh与远程主机建立连接,然后scp在该主机上启动该程序的另一个副本来工作。这两个scp实例通过ssh连接进行通信以执行文件传输。

scpssh连接过早断开时,本地程序将打印“丢失的连接” 。造成这种情况的常见原因是scp远程主机上的程序无法启动或过早退出。之所以会发生这种情况,是因为远程主机上不存在scp程序,或者该程序不在您的命令PATH中,或者没有标记为可执行文件,或者在启动后崩溃了,或者类似的东西。


0

我们最近在一个系统上遇到了这个问题。

我们可以适当地SSH到主机服务器上,但是发现我们无法从服务器SSH到机器上。这是一个调查的好地方,如果您不能执行此操作,则将无法使用SCP。

在我们的情况下,以某种方式(也许是错误安装)将ssh二进制文件替换为0字节的空文件。无论何时执行“ ssh”,都不会发生任何事情。

通过重新安装openssh-clients,我们纠正了二进制文件,并且scp开始工作。

yum reinstall openssh-clients

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.