大网数据广告活动
服务器运维问答

SFTP Error - Couldn't read packet: Connection reset by peer

· 52CE 我爱测

I try to configure SFTP on Centos 7, on my first server it works perfectly, but on my second server when I try to connect me with : sftp USERNAME@serveripaddress I have this error : Could not read packet: Connection reset by peer…

问题原文

原帖链接 · Olaf · CC BY-SA 3.0

I try to configure SFTP on Centos 7, on my first server it works perfectly, but on my second server when I try to connect me with :

sftp USERNAME@serveripaddress

I have this error :

Could not read packet: Connection reset by peer

I use this method :

adduser USERNAME
passwd USERNAME
groupadd sftp_only
usermod -aG sftp_only USERNAME

Configure SSH chroot :

vi /etc/ssh/sshd_config

Add a comment :

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

Add the line after :

Subsystem sftp internal-sftp

Add at the end of the file :

Group sftp_only Match
ChrootDirectory /var/www
ForceCommand internal-sftp
X11Forwarding No
AllowTcpForwarding No

Restart SSH :

service sshd restart

I have the same iptables rules on my 2 servers and I try with iptables disabled.

Maybe I need to install an FTP server like VSFTPD ?

Thank you to help me because I'm completely blocked since several hours.

社区高分解答

原帖链接 · Sérgio · CC BY-SA 4.0

cat /var/log/auth.log

May 10 17:08:32 machine sshd[31902]: fatal: bad ownership or modes for chroot directory component "/var/www/html/nextcloud/"

that was my problem

After we can follow this one bad ownership or modes for chroot directory component

BTW I end up using bind solution Need help - limit access to sftp user to other users home->subfolder

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-03-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。