Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 31849  / 2 Years ago, wed, august 24, 2022, 4:42:30

In my ubuntu 14.04 I installed the (FTPD) ftp server. I would like to create one user for that and set nologin to that user. When logging on using an FTP client, I want that particular user to be able to see the entire system directory.



How do I restrict one user like that to one directory (E.g. /usr/local/example)?


More From » ftp

 Answers
7

For vsftpd (“Very Secure File Transfer Protocol Daemon”), the configuration is exceedingly simple:


sudo apt-get install vsftpd

then:


sudo nano /etc/vsftpd.conf

ensure you have the following parameters set right:


# Depending on the version you're running, you might want to set the following 
# parameter to YES
# (if affected by https://bugs.launchpad.net/ubuntu/+source/vsftpd/+bug/1313450)
listen=YES
# to allow local users to log on:
local_enable=YES
#if you want write access too:
write_enable=YES
# Set anonymous user directory to /srv/ftp (no default)
anon_root=/srv/ftp
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES

# following for debugging purposes (to ensure you're on the right server)
ftpd_banner=Welcome to Aravind's FTP service.

# Now restrict users to their home directories:
chroot_local_user=YES
allow_writeable_chroot=YES

And now, if you want to set a particular user to a particular directory, just create a user with a particular directory:


sudo adduser ftpuser --home /usr/local/example

To test:


Go to a terminal on the machine running vsftpd and type: ftp 127.0.0.1 and if you're greeted by your own banner, vsftpd works!


Then test on the same machine to its public address: ftp 1.2.3.4 and finally from a remote machine to the public address. If something goes wrong with the public addresses, check your firewall settings.


Additional notes:


If you don't want the user to log on, add the --shell /bin/false parameter to the adduser command.


You might also want to delete all the directories/files (Desktop, Pictures, ... that the adduser created if you don't want them there...


Done!


[#20158] Thursday, August 25, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oargrou

Total Points: 336
Total Questions: 105
Total Answers: 113

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
;