# SFTP disconnects right after login

UrbeStack sysadmin note about OpenSSH. Last updated 30 Nov 2026.

A customer's SFTP session closes at login, and OpenSSH logs `fatal: bad ownership or modes for chroot directory "/home/USER" [postauth]`. The customer's top folder must belong to root, and one command restores that ownership.

## Symptoms

The SFTP client disconnects right after login with an error such as `Connection reset by peer`.

Check the `sshd` log with `journalctl -u sshd` on AlmaLinux or `journalctl -u ssh` on Ubuntu. It shows the following error.

```output
fatal: bad ownership or modes for chroot directory "/home/USER" [postauth]
```

## Cause

SFTP confines each customer to `/home/USER`. The `sshd` service requires root to own that folder and every parent folder. Only root may have write permission on those folders.

Using `chown` to give the customer ownership of `/home/USER` breaks that requirement. This can happen when you run `chown -R` on the home folder. The customer's own files are in `/home/USER/files`.

## Resolution

Preview the changes UrbeStack would make.

```
urbestack-home-repair --name USER --dry-run
```

The preview lists a change for `/home/USER` from `USER:root` to `root:root`. Apply the repair.

```
urbestack-home-repair --name USER
```

The folder `/home/USER` now has ownership `root:root` and mode `0755`. Log in over SFTP again.

If the problem persists after you follow this note, you can [open a support ticket](https://support.urbestack.com/new?type=support). Including the output of the commands you ran helps support diagnose the problem.
