尝试连接到 sftp 服务器时连接已关闭。匹配组问题?

尝试连接到 sftp 服务器时连接已关闭。匹配组问题?

我正在尝试使用以下命令连接到 Ubuntu 服务器 14.04 LTS:sftp -P xx user@host(ssh 服务器配置为监听不同的端口)。我尝试登录的用户是服务器上的主要用户帐户(我在安装服务器期间放弃的帐户)。每次我尝试使用连接到服务器时,sftp我都会收到消息Connection closed

我很确定这与我在 中所做的添加有关sshd_config,但我看不出哪里出了问题。以下是全部内容sshd_config

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 2222
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp internal- sftp

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

Match Group sftpusers
        ChrootDirectory /var/www/Vassens
        # XllForwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp

我尝试登录的主要用户帐户是不是'sftpusers' 组的成员。我能够以另一个用户身份登录,‘sftpusers’ 的成员。

当我尝试连接时,身份验证成功后会发生以下情况:

debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LC_PAPER = nl_NL.UTF-8
debug1: Sending env LC_ADDRESS = nl_NL.UTF-8
debug1: Sending env LC_MONETARY = nl_NL.UTF-8
debug1: Sending env LC_NUMERIC = nl_NL.UTF-8
debug1: Sending env LC_TELEPHONE = nl_NL.UTF-8
debug1: Sending env LC_IDENTIFICATION = nl_NL.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = nl_NL.UTF-8
debug1: Sending env LC_TIME = nl_NL.UTF-8
debug1: Sending env LC_NAME = nl_NL.UTF-8
debug1: Sending subsystem: sftp
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 4672, received 2772 bytes, in 0.6 seconds
Bytes per second: sent 7385.2, received 4381.8
debug1: Exit status 127
Connection closed

理想情况下,我可以sftp使用主用户帐户登录,这样我就可以将文件从我的笔记本电脑传输到我的服务器的任何我想要的目录,同时保留只能登录的“sftpusers”组/var/www/

有人知道我该怎么做吗?非常感谢您的帮助!顺便说一句,我可以使用 以主用户帐户登录服务器ssh

答案1

退出状态 127 表示未找到命令。

您的 sshd_config 显示:Subsystem sftp internal- sftp

该行应该是Subsystem sftp internal-sftp(内部和 sftp 之间没有空格),否则您的 sshd 会尝试将其作为外部命令执行并失败。

相关内容