Patrick asks:
How do I limit users of vsftp to only their home directory? Therefore, that user cannot go outside other directories to browser something.

Yesterdays VSFTPD troubleshooting note (read as post) brought me back this question.

If you do not wish FTP users to be able to access any files outside of their own home directory, set up chroot jail.

For consider following example:

  • Ftp username : user1
  • FTP home directory: /home/user1

$ ftp


Connected to
220 (vsFTPd 2.0.5)
Name ( user1
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/user1"
ftp> cd /etc
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
150 Here comes the directory listing.
-rw-r--r--    1 0        0            7959 Mar 02 22:20 Muttrc
drwxr-xr-x    3 0        0            4096 Jul 24 12:20 Wireless
drwxr-xr-x   16 0        0            4096 Jul 30 22:58 X11
drwxr-xr-x    4 0        0            4096 Sep 05  2005 Xprint
-rw-r--r--    1 0        0            2188 Sep 05  2005 adduser.conf
-rw-r--r--    1 0        0              47 Aug 16 14:52 adjtime
-rw-------    1 0        0            4330 Aug 18  2005 afick.conf
-rw-r--r--    1 0        0             194 Sep 05  2005 aliases
-rw-r--r--    1 0        0           12288 Jul 19 21:27 aliases.db
drwxr-xr-x    2 0        0            8192 Aug 15 09:33 alternatives

Now normal user can go to /etc directory (may be to all other directories) and if there is read only permission to sensitive files user can download the file via ftp.

To avoid this security problem you can lock ftp user in a jail.

Open vsftpd configuration file – /etc/vsftpd/vsftpd.conf
# vi /etc/vsftpd/vsftpd.conf

Make sure following line exists (and uncommented):

Save and close the file. Restart vsftpd.
# /etc/init.d/vsftpd restart

Now all users of VSFTPD/FTP will be limited to accessing only files in their own home directory. They will not able to see /, /etc, /root and /tmp and all other directories. This is an essential security feature.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 50 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
50 comments… add one
  • Tyler Mar 16, 2007 @ 2:33

    What if I need a ‘root’ type FTP account; I want to chroot all but one user?

  • Bassist Mar 20, 2007 @ 18:43

    “What if I need a ‘root’ type FTP account; I want to chroot all but one user?”

    Create a user account with the root directory as the server root directory i.e. ‘/’. Or for better security, use the main directory of all sub-directories you would like to access, as the home directory. e.g. if you have ftp accounts for /var/www/html2 and /var/www/html3, then use /var/www as the home directory for the main ftp account.

  • joel Mar 23, 2007 @ 8:34

    i have just installed cerberus ftp server inside my network with an ip address of 192.168.x.xx…problem is i cannot connect with it outside because i really don’t knw(noobs) how to forward port 21 to it from my internet gateway.btw, my gateway runs on mandrake 10.can u tell me what to do specifically the commands to make it work? many thanks…

    • Anon Junior Oct 27, 2012 @ 15:50

      192.168.x.x is a private IP. If you only have one static or dynamic IP shared between all computers on the network, even if multiple gateways and subnets are used. Then use port forwarding. Doing a google search will suffice.

  • 🐧 nixCraft Mar 23, 2007 @ 15:18


    You can use port forwarding from your router itself. If you want software based port forwarding use –
    Internet TCP redirection server called rinetd. You can also use iptabled DNAT rules for same.

  • joel Mar 24, 2007 @ 1:19

    hi nixcraft,

    thanks for the reply.i was just wondering can i just add this rule to your fw_proxy script that you made..

    iptables -t nat -I PREROUTING -p tcp -i INTERNET –dport 21 -j DNAT –to 192.168.x.xx:21

    will that work or is there anything else that i should add?

    thanks again 🙂

  • joel Mar 26, 2007 @ 2:41


    sorry, fw.proxy was posted by vivek,my apologies to him and to you also.anyway im still on my problem.i have installed fw.proxy script on my gateway machine running mandrake 10 and run all the commands there.even tried adding the iptable rule that i have just mentioned but i still cannot connect outside my totally out of my mind figuring it out how to work.pls bail me out on this one…


  • 🐧 nixCraft Mar 27, 2007 @ 5:21

    Lan is at eth0 and internet is eth1 (to isp router)

    Gateway ip is
    FTP server is at

    You want to redirect to at port 21, use following
    iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 21 -j DNAT --to-destination


  • Robert O'Rourke Dec 19, 2007 @ 15:02


    I’ve been trying this on a redhat system but its not restricting the user to their home directory. It’s all they have permission on but they can still list all the files under /,/dev,/bin etc…

    It might be because I have a symlink in their home folder to another part of the file system they have permission on. Would it be better to make the symlink the other way around? I’ve done everyhitng I can work out that I need to do so I don’t get why they can sill list any other directories…


  • Paul Dec 24, 2007 @ 16:14

    Ref: chroot ftp users. This is taken from the vsftpd.conf file:

    # You may specify an explicit list of local users to chroot() to their home
    # directory. If chroot_local_user is YES, then this list becomes a list of
    # users to NOT chroot().

    This works very well for my systems.

    • Matt Borja Oct 6, 2011 @ 16:14

      This is also required on some dedicated servers and cloud solutions (e.g. Rackspace). Having chroot_local_user=YES is not sufficient in such cases and requires chroot_list_enable and chroot_list_file to both be uncommented.

      Also, it’s probably worth mentioning that while this will chroot FTP users, it will not chroot SFTP over SSH users. This is an upcoming feature that will be present in CentOS 6, but as of now, Ubuntu, all current distributions of Red Hat, and CentOS 5 do not support chrooting of SFTP/SSH accounts

  • Mentor Jan 14, 2008 @ 15:57


    I want to be able to add another folder to the list of folders that the users are permitted to use.


    Is this possible?

    Rgds. Mentor

  • Happy Jan 25, 2008 @ 8:33

    Thank you very much…Works like a charm…

  • Chris Hunt Feb 3, 2008 @ 15:43

    You can use the command “mount –bind olddir newdir”. The call ‘–bind’ mounts part of the file system to another area. You may have try to use links but these are prohibited for security reasons.

  • br0ken rlz May 12, 2008 @ 15:17

    hi guys
    i face this problem and i do the solution up
    but the same thing nothing change the user can
    able to see / & /etc
    and i have question
    what i put in chroot_user_list file
    only the username ?
    need your advice

  • Ajay May 22, 2008 @ 10:56

    Suppose if I have 5 users, I want to limit only 2 users to their home directory and remaining users to have full access. How to do that?

  • modjo-jojo Oct 15, 2008 @ 13:40

    Ajay, you have 2 options:

    .) chroot_local_user=YES
    Where file /etc/vsftpd/nonchroot.list should contail the users you don’t want to chroot.

    .) chroot_list_enable=YES
    Where the file etc/vsftpd/chroot.list should contain the users you want to be chrooted to their home. By default all other users should have access to the / (root).


    • ug Aug 17, 2012 @ 15:17

      Useful information. It helped me.

  • Stan Jan 14, 2009 @ 12:35

    Thanks Chris! I’ve been looking for ways to mount my FTP pub directory in home dir of some users… This solution have finally solved my problems. Keep the good work. Thanks.

  • Bjarte Aune Olsen Feb 1, 2009 @ 17:31

    I have the same problem as some others have mentioned. When “chroot_local_user” is set to NO, the user starts up in his home folder, and can navigate everywhere on the system. When “chroot_local_user” is set to YES, the user can only WRITE to his home directory, but he can navigate anywhere and see the whole folder structure of the machine, which I don’t like.

    Even worse, when “chroot_local_user” is set to YES, the user starts up in the root folder, “/” and not in his home directory. Which means that if he isn’t that familiar with Linux system, he will have a hard time finding his home directory where he’s able to upload files.

    – Bjarte

  • Mizan Feb 3, 2009 @ 13:07

    I have a Apache webserver. I want to access the thml directory to my web developer so that he can upload file through ftp. I use vsftp server. I careate a user for him and assing /var/www/html as home directgory. the problem is when he want to upload file it shows “File could not be opended by server. 553 could not create file” . I think it is permission problem. What permision can I provide the user to mention directory without sacrifice the security. thank you.

  • Martin Mar 15, 2009 @ 22:36

    To Bjarte Aune Olsen:
    search in the configuration file the directive local_root=… and comment it out (thus local_root will be unset). If this directive was set then vsftpd always respect him, so after loging in, he put the user in the directory that was set by local_root=…
    I hope that will help you.


  • srinivas Jun 9, 2009 @ 6:10

    my vsftpd setup has following

    ->useradd -d /var/www/html/site ftpupload
    ->chown ftp:ftp /var/www/html/site
    ->chmod g+w /var/www/html/site
    ->vi /etc/vsftpd/vsftpd.conf
    -> vi /etc/vsftpd/chroot_list

    this works fine when i tried from command mode from another linux
    box using both ftp and lftp commands and my user restricting to his home

    this is the same with the case if i use WinSCP with ftp as protocol.
    but if i use sftp as the protocol i am able to chroot to another directories too

    anybody has this problem ??
    i need help..

    Thanks in advance

  • Bineesh Jul 3, 2009 @ 9:34

    How i can configure different chroot directory for different users.

  • Vikas Singh Jul 23, 2009 @ 12:13

    Hi, All
    I have configure ftp in fc5.
    but when I trying to access my ftp from web (ftp://X.X.X.X) it is not asking for username and passwd but I can access it ftp://username@X.X.X.X. I m not understanding why?

  • Matt J. Sep 8, 2009 @ 8:08

    Hi, Vikas-

    If your browser implements the spec (RFC1738) correctly, then in the case where you specify no user name, it will assume the user name is ‘anonymous’. Now back in the days when the spec was written, the password for ‘anonymous’ was an email address. But this is not so common now. Now the password is usually also ‘anonymous’.

    That is the difference between “ftp://X.X.X.X” and “ftp://username@X.X.X.X”. So the behavior you describe sounds like the browser is doing the right thing.

  • Muhammad Babar Mar 2, 2010 @ 7:24

    I configure a vsftpd server and they work but when i access through browser they open “Log On As” window but we can’t login. i don’t know why this happen.
    but we can access through cmd.
    We want to access my Home directory through internet-explorer.
    Plzz help meee

  • Ray Mar 2, 2010 @ 7:31

    Hey gyus, i did the chroot_local_user=yes
    chroot list enable=yes
    add the user names on /etc/vsftpd/chroot_list
    still when logging I go everywhere on /

    Any ideas?


    • Phil Jun 5, 2010 @ 23:33

      If you put people in the chroot_list thats people that are NOT going to be restricted to there home directory. leave chroost list enable commented out, skip adding names to the list and just use chroot_local_user=yes

      peace easy

      • Brian Jun 8, 2010 @ 20:29

        Works great with regular FTP, but does not jail users when using SFTP. How would I do that?

        • 🐧 nixCraft Jun 8, 2010 @ 20:42

          VSFTPD = FTP server
          SFTP = OpenSSH server, so you need to chroot OpenSSH user. OpenSSH 5.x series do have inbuilt support for jailing users to their directories.

          Another option is to run vsftpd with SSL support only.

        • Nandakumar Sep 2, 2010 @ 12:16

          Brian 🙁 ….you are right. Nobody has said this that chroot not jail the user, I have wasted my time doing chroot on sftp and nothing happened yet, after seeing your post i just commented all the sftp option in vsftp config file. now i am seeing that jailing option working. Thanks a lot 🙂 you saved me.

          But still my task incomplete how to jail the user in sftp and how make this ftp work in browser (integrate with apache) ?

          I am newbie so please don’t mistake me if raised silly questions.
          Please help me…

      • steven Jun 30, 2010 @ 7:34

        even only set chroot_local_user=yes. it still limit user to “/” ,rather than user’s home directory. any idea how to fix this ?

        • Xavi Aug 10, 2011 @ 9:50

          Check that


          is commented in your etc/vsftpd.conf file (if not, it’ll go ever to / or whatever it’s put there). Cheers

    • Xavi Aug 10, 2011 @ 9:51

      Check that


      is commented in your etc/vsftpd.conf file (if not, it’ll go ever to / or whatever it’s put there). Cheers

  • Danzo May 3, 2010 @ 15:20

    Edit /etc/passwd

    change :/bin/bash to /./:/bin/bash

    That should work.

    However ftp://x.x.x.x, users remain in home directories but sftp:x.x.x.x, users can access other directories.

    any advice on that one

  • Nandakumar Sep 2, 2010 @ 10:58

    I am also facing the problem like user can able to access all the folders without any restriction. I have enabled all the above said option but none of them working. I have two issues one i am not able to access ftp via browser and another one any user can access any folder with out any control. could anybody can help me to solve this issue ?


    • Nandakumar Sep 2, 2010 @ 12:16

      Brian 🙁 ….you are right. Nobody has said this that chroot not jail the user, I have wasted my time doing chroot on sftp and nothing happened yet, after seeing your post i just commented all the sftp option in vsftp config file. now i am seeing that jailing option working. Thanks a lot 🙂 you saved me.

      But still my task incomplete how to jail the user in sftp and how make this ftp work in browser (integrate with apache) ?

      I am newbie so please don’t mistake me if raised silly questions.
      Please help me…


  • Jon May 24, 2011 @ 9:53

    I could use some help for the following:
    1) local user (myself) need complete access to update wordpress and by default I have what I need with the following:

    2) I have a web developer that requires access to another folder

    How do I give him access to this domainname folder, and only that location and what lies under it? i.e the subfolder of the domainname folder. I do not want him to be able to change directory from that folder.


    • Joseph Nov 26, 2011 @ 6:57

      Hi Jon,

      How to give yourself full access while still restricting others using vsftpd:

      add or Uncomment the following in /etc/vsftpd/vsftpd.conf

      create a file called /etc/vsftpd/chroot_list (it is case sensitive)
      write your user name for admin access on line 1
      save the file

      you will be exempt from being locked in your home directory however all other users will still be locked in their home directory.

      And specifically in your case remove the line chroot_local_user=NO

      Reboot your server for changes to take effect.

      Here is the shell command for adding a user to a currently existing home directory: (directory must already exist and is case sensitive)

      mkdir /home/mystuff
      groupadd ftp_users
      chmod 777 /home/mystuff
      useradd -g ftp_users -d /home/mystuff user1

      This will create a password for the user1 account:
      passwd user1

      Best of Luck,


  • Babu Jan 19, 2012 @ 21:58

    I have been trying all the possible options provided by you guys to jail the user to his assigned path. But, I was unsuccessful to do it.
    Is there any expert who can advise me to proceed on it.

    Your timely help would greatly help me out.

  • kirk Mar 13, 2012 @ 22:28

    for xtra security create a seperated group and user account with no shell acces.

  • Aurelian Mar 16, 2012 @ 11:18

    I have a problem and, after reading this, I couldn’t resolve it:
    I want that a ftp user should acces /home/ftpuser and /home/share but it should NOT acces /etc or other important system directories.

    How can I do that?
    If I chroot that user, he can see /home/ftpuser but he cannot see /home/share
    If I do NOT chroot that user, he can see /home/ftpuser, /home/share and /etc.

    I do not like the “mount -bind /home/share /home/ftpuser” solution.

    Thank you alot!

    • amila Mar 13, 2013 @ 12:11

      Uncomment following and,

      edit “/etc/vsftpd.chroot_list”
      and put any jailed users usernames in to it

  • Stopmotionheaven Aug 14, 2013 @ 16:38

    Thanks! Very usefull!

  • 4lvin Sep 13, 2013 @ 4:22

    But how about jailing a “SPECIFIC USER ONLY” ?

  • mukesh Aug 13, 2014 @ 7:40

    how to restrict FTP users not to delete their files once upload… plz help..

  • mukesh Aug 13, 2014 @ 7:41

    how to restrict FTP users not to delete their files

  • ali epsilon Dec 12, 2014 @ 10:08

    i change chroot_local_user=YES but not jail

  • Loui Jan 8, 2015 @ 15:19

    Having similar issues with everyone elses comments on here. Having edited etc/vsftpd.conf with chroot_local_user=YES, new user still login to :/ and not specific directory.

    Where is the problem?



Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum