How to change vsftpd's default directory to / instead of the user's home directory?
Solution 1
Just add this line to /etc/vsftpd.conf
:
local_root=/
Restart the vsftpd service to apply the changes:
sudo systemctl restart vsftpd
Essentially, you can set it to whatever directory you want. You also can use $USER
in the path, it will be replaced with user's login.
So, if you set local_root
, for example, to /home/$USER/ftp
, then when a user connects to your server, he will be directed to the ftp
folder in his home directory.
Solution 2
You can create a chroot list with vsftpd.conf Check this
All the users belonging to ftp-users group goes into /home/ftp-docs/ftp_stuff by default when they login. They cannot navigate in other directories and are restricted to this particular directory.
You do this:
Create a directory by issuing the following command as root:
mkdir -p /home/ftp-docs/ftp_stuff
Then do this:-
chgrp ftp-users /home/ftp-docs/ftp_stuff chmod 3777 /home/ftp-docs/ftp_stuff
In the /etc/vsftpd/vsftpd.conf
write this chroot_list_enable=YES chroot_list_file=/etc/vsftpd.chroot_list
Put all you ftp-users group userś name in /etc/vsftpd.chroot_list
Then in the /etc/passwd
file make the home directory of all the users belonging to ftp-users group to /home/ftp-docs/ftp_stuff
. Then do the following:
service vsftpd restart
Then login via any user belonging to ftp-users group you will lend into /home/ftp-docs/ftp_stuff
. You cant go to the other higher level directories.
you can create multiple entries in the list for multiple groups. the order in which those groups are in the list file will dictate their highest directory I believe.
Solution 3
Let me give you three lines for your VSFTPD.CONF
file.
chroot_local_user=YES
allow_writeable_chroot=YES
local_root=/
Last line is the path where the user will land on authentication. You wanted it to be the root, so it is root (/
). 1st two lines will lock the user in the land directory, which is the root. All you need is to #
first two lines which means user will land in root directory but will not be locked to it and can change folders.
Related videos on Youtube
Fre_d
Updated on September 18, 2022Comments
-
Fre_d over 1 year
I currently have vsftpd installed in such a way, that when a user, say for instance my account
frederik
authenticates, I will be directed to my home directory/home/frederik/
.This is a problem for certain FTP clients, as they can not change to anything outside that default folder, for instance
/home/
(even given permission).How can I change it so that authenticated users gets directed to
/
instead?-
HATEthePLOT about 8 yearsMaybe you won't have to do this. Check this link: vsftpd.beasts.org/vsftpd_conf.html especially your settings of
chroot
for users. -
Eliah Kagan almost 7 years
-
-
Fre_d about 8 yearsI'm not trying to jail my users to a specific directory. I'm trying to have all users go to the / directory upon authentication.
-
Константин Ван almost 5 years“This option represents a directory which vsftpd will try to change into after a local (i.e. non-anonymous) login. Failure is silently ignored.”