Creating FTP user to access a specific directory with SFTP in Linux Ubuntu Server 14.04 LTS
Change the owner of your /var/www/html/mydir with below command
sudo chown -R root:ftpgroup /var/www/html/mydir
check this one for reference http://devtidbits.com/2011/06/29/implement-a-sftp-service-for-ubuntudebian-with-a-chrooted-isolated-file-directory/
Related videos on Youtube
Dakkar
Updated on September 18, 2022Comments
-
Dakkar over 1 year
I'm creating an FTP user on Linux Ubuntu Server 14.04 LTS, but when I try to log in via FileZilla with SFTP I get the following error:
Received unexpected end-of-file from SFTP server
If I try to connect with my root user everything's fine, so I must have missed something in the new user creation. Here's what i did:
First of all I created a fake shell in /etc/shells naming it /bin/false I create a group named ftpgroup
sudo groupadd ftpgroup
Then I created the ftp user within it
sudo useradd --home /var/www/html/mydir --group ftpgroup --shell /bin/false myftpuser
I gave a password to the user
sudo passwd myftpuser
And made it the owner of the home directory i gave him
sudo chown -R myftpuser /var/www/html/mydir
finally I set up privileges for the folder
sudo chmod 755 /var/www/html/mydir
I'm aware that changing the /bin/false shell to /bin/bash would make it work, but that would give my user the ability to access shell commands, which I would avoid if possible, I just want him to access files in his own directory and nothing more.
-
Dakkar about 9 yearsI tried your solution, but if I leave ChrootDirectory %h I can't access, I get a "Network error: Software caused connection abort". Without that line it works, but I'm able to access parent directory, which is not the desired behaviour.
-
Janne Pikkarainen about 9 yearsSince you have only one user to match against, try
ChrootDirectory /home/myftpuser
or so. Also check out the directory permissions. -
Dakkar about 9 yearsSame behaviour. The user owns the directory, and permission are 777.