CentOS 6 上的 SFTP 错误“从 SFTP 服务器收到意外的文件结束”

CentOS 6 上的 SFTP 错误“从 SFTP 服务器收到意外的文件结束”

我在 CentOS 6 上收到此 SFTP 错误“从 SFTP 服务器接收到意外的文件结束”。

我在下面添加了一个新用户

sudo adduser --shell /bin/false paul

sudo 密码 paul

然后编辑 /etc/ssh/ssh_config 以包含此内容并重新启动 sshd 服务

#   $OpenBSD: ssh_config,v 1.25 2009/02/17 01:28:32 djm Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   Port 22
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
Host *
    GSSAPIAuthentication yes
# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
    ForwardX11Trusted yes
# Send locale-related environment variables
    SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES 
    SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT 
    SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
    SendEnv XMODIFIERS
UseRoaming no

Subsystem sftp internal-sftp

Match User paul
    ForceCommand internal-sftp
    PasswordAuthentication yes
    ChrootDirectory /var/www/vhosts/****/httpdocs/gold
    PermitTunnel no
    AllowAgentForwarding no
    AllowTcpForwarding no
    X11Forwarding no

我搜索过类似的问题,大多数只是说添加

Subsystem sftp internal-sftp

我已经这样做了,但没有帮助。是什么导致了这个错误?

编辑:

以下是 /var/log/secure 的日志内容

Oct  4 16:34:45 WEBDB sshd[50124]: Accepted password for paul from *.*.*.* port 7093 ssh2
Oct  4 16:34:45 WEBDB sshd[50124]: pam_unix(sshd:session): session opened for user paul by (uid=0)
Oct  4 16:34:45 WEBDB sshd[50126]: subsystem request for sftp
Oct  4 16:34:45 WEBDB sshd[50124]: pam_unix(sshd:session): session closed for user paul

答案1

我相信您应该将其添加Subsystem sftp internal-sftp 到 /etc/ssh/sshd_config
(而不是 /etc/ssh/ssh_config)

答案2

如果你看一下/var/log/secure文件,你会看到这样的消息

pam_unix(sshd:account): expired password for user <username> (password aged)

因此,这意味着您必须为指定/相应的用户创建一个新密码。

相关内容