SFTP Connection Fails with "Connection reset by peer" After Directory Permissions Are Set to 777

Solution In Progress - Updated -

Issue

A connection using SFTP (Secure File Transfer Protocol) successfully authenticates and establishes a channel, but the connection is immediately terminated by the remote host with the error Connection to closed by remote host followed by Couldn't read packet: Connection reset by peer.

The failure occurs specifically after a user attempted to grant maximum permissions by setting the directories (e.g., /ftp/MY_TEST) to 777 (read, write, execute for all) and changing ownership away from root.

The verbose debug log shows the connection terminating after successful authentication:

debug1: Authentication succeeded (keyboard-interactive).
Authenticated to XXX.XXX.XXX.XXX ([XXX.XXX.XXX.XXX]:22).
...
debug1: channel 0: new [client-session]
...
debug2: channel 0: send open
debug3: send packet: type 90
...
Connection to XXX.XXX.XXX.XXX closed by remote host.
...
Couldn't read packet: Connection reset by peer

Environment

  • Red Hat Enterprise Linux 7, 8, or 9
  • OpenSSH Server
  • Server configured to use a restricted SFTP environment (i.e. ChrootDirectory ).
  • SFTP connections.

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content