sftp 错误,连接已关闭

sftp 错误,连接已关闭

我正在尝试使用密码通过 sftp 进入 Amazon Linux 系统。

我创建了一个帐户“amitd”,设置了密码,并且修改了 /etc/ssh/sshd_config 以设置“PasswordAuthentication yes”,然后我退出了 sshd。

我尝试通过 ssh 和 sftp 登录,没有问题,一切看起来都很好。

但是,我希望该帐户仅用于 sftp,因此我再次编辑 /etc/ssh/sshd_config,并添加:

Match User amitd
        ChrootDirectory /disk1/%u
        ForceCommand internal-sftp
        X11Forwarding no

我创建了“/disk1/amitd”并确保它归 amitd 所有,然后再次重新启动 sshd 服务器。

现在,我尝试使用 ssh 登录,并得到:

mjb@feynmann:~/PEMs_and_PPKs$ ssh  [email protected]
[email protected]'s password: 
Connection to 172.24.5.159 closed by remote host.
Connection to 172.24.5.159 closed.

这很好,这也是意料之中的。

当我尝试使用 sftp 登录时,我得到:

mjb@feynmann:~/PEMs_and_PPKs$ sftp [email protected]
[email protected]'s password: 
Connection to 172.24.5.159 closed by remote host.
Connection closed.  
Connection closed

这对我来说毫无意义。

如果我这样做:

ssh -vvv [email protected]

我得到:

<...omitted all logging before the password prompt...>
[email protected]'s password: 
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to 172.24.5.159 ([172.24.5.159]:22).
debug2: fd 4 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t3 nr0 i0/0 o0/0 e[write]/0 fd 4/5/6 sock -1 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
Connection to 172.24.5.159 closed by remote host.
Transferred: sent 2396, received 1740 bytes, in 0.0 seconds
Bytes per second: sent 13579383.0, received 9861488.5
debug1: Exit status -1
Connection closed

帮忙?有人能给我提供线索吗?

编辑:添加信息:我尝试明确启用 internal-sftp,但仍然无法登录。C 传递 /etc/ssh/sshd_config:

#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem       sftp    internal-sftp

退回 sshd,但仍然有错误:

[email protected]'s password: 
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to 172.24.5.159 ([172.24.5.159]:22).
debug2: fd 4 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t3 nr0 i0/0 o0/0 e[write]/0 fd 4/5/6 sock -1 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
Connection to 172.24.5.159 closed by remote host.
Transferred: sent 2396, received 1740 bytes, in 0.0 seconds
Bytes per second: sent 1055821.0, received 766748.2
debug1: Exit status -1
Connection closed.  
Connection closed

相关内容