Attempting to setup an SFTP server on a mounted hard drive, and have followed the instructions from a bunch of tutorials, always get "client_loop: send disconnect: Connection reset" on login.
I started by creating a group called sftp, then assigning a user to that group with its home directory in the HDD:
sudo useradd -g sftp -d /media/linux/MyHDD/NAS/USERNAME -s /sbin/nologin USERNAME-nas sudo passwd USERNAME
Where USERNAME is my personal username
I then attempted to set ownership of everything above the USERNAME folder to root and the USERNAME folder to the user:
sudo chown -R root:root /media sudo chown -R USERNAME:sftp /media/linux/MyHDD/NAS/USERNAME
Editted the sshd_config file to contain:
Subsystem sftp internal-sftp Match Group sftp ChrootDirectory /media/linux/MyHDD/NAS/USERNAME ForceCommand internal-sftp AllowTcpForwarding no X11 Forwarding no
Not forgetting to restart the sshd service
sudo systemctl restart sshd
As I wanted to access this folder on my linux computer, I set the permissions to 777 for the media folder
sudo chmod -R 777 /media
After doing all this, when attempting to login to sftp and entering password I am greeted with:
sftp -P PORTNO USERNAME@IP client_loop: send disconnect: Connection reset Connection closed
Is this a permissions issue, or possibly an ownership issue, I don't know. I have spent a long time on this and cannot seem to figure it out, so any help would be appreciated.