Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FTP - How to log into a specific folder and restrict all disk shares.

Featured Replies

I have been able to get VSFTP working with a user and login I created in unraid.  However when a user logs in to the server via FTP - they can see every single disk share.  

 

How can I create it so that when a user logs in - they are directed to or only see one specific directory?  

 

Do I need a more robust FTP solution?  Is there an edit that can be made to the vsftp.conf file to configure this?  Do I need to try Proftpd?

 

I have read nearly every single FTP thread here and I can't seem to find the exact solution.  I am so desperate to get this working I am willing to do some kind of paid support if someone knows that they are doing.

 

Let me know.

 

Thank you

Jesse

 

I have been able to get VSFTP working with a user and login I created in unraid. 

However when a user logs in to the server via FTP - they can see every single disk share. 

How can I create it so that when a user logs in - they are directed to or only see one specific directory?

 

Let's say for example that you want to share the following things over ftp:

1. Disks 2 and 4, but not any other disks.

2. Folder "Music" which you have on disk 6.

3. User share "Stuff" which you've created with the unRAID's web interface.

 

My first thought was to just redirect the vsFTPd's local_root to a new empty directory,

and then use symbolic links for the things that we want to share.  Unfortunately, that won't work.

The thing is, sFTPd doesn’t allow browsing symbolic link targets when their target is outside the user’s chroot.

So, the mount command comes to the resque.  ;)

 

Here's your solution.  Put the following commands at the end of your 'go' script:

sleep 30
mkdir -p /var/ftproot/disk2
mkdir -p /var/ftproot/disk4
mkdir -p /var/ftproot/Music
mkdir -p /var/ftproot/Stuff
echo 'anon_umask=0022' >> /etc/vsftpd.conf
echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf
mount --bind  /mnt/disk2        /var/ftproot/disk2
mount --bind  /mnt/disk4        /var/ftproot/disk4
mount --bind  /mnt/disk6/Music  /var/ftproot/Music
mount --bind  /mnt/user/Stuff   /var/ftproot/Stuff

 

Enjoy!

 

  • Author

I have been able to get VSFTP working with a user and login I created in unraid. 

However when a user logs in to the server via FTP - they can see every single disk share. 

How can I create it so that when a user logs in - they are directed to or only see one specific directory?

 

Let's say for example that you want to share the following things over ftp:

1. Disks 2 and 4, but not any other disks.

2. Folder "Music" which you have on disk 6.

3. User share "Stuff" which you've created with the unRAID's web interface.

 

My first thought was to just redirect the vsFTPd's local_root to a new empty directory,

and then use symbolic links for the things that we want to share.  Unfortunately, that won't work.

The thing is, sFTPd doesn’t allow browsing symbolic link targets when their target is outside the user’s chroot.

So, the mount command comes to the resque.  ;)

 

Here's your solution.  Put the following commands at the end of your 'go' script:

sleep 30
mkdir -p /var/ftproot/disk2
mkdir -p /var/ftproot/disk4
mkdir -p /var/ftproot/Music
mkdir -p /var/ftproot/Stuff
echo 'anon_umask=0022' >> /etc/vsftpd.conf
echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf
mount --bind  /mnt/disk2        /var/ftproot/disk2
mount --bind  /mnt/disk4        /var/ftproot/disk4
mount --bind  /mnt/disk6/Music  /var/ftproot/Music
mount --bind  /mnt/user/Stuff   /var/ftproot/Stuff

 

Enjoy!

 

 

You are my savior!  Works like a charm!  Exactly what I needed!  Thank you so much!

 

You are welcome.  8) 

 

 

 

You are welcome.   8) 

 

 

You may need to un-mount everything before the array can be stopped.  just an advisory so you don't panic.

 

Just type

umount /var/ftproot/disk2

etc...

 

You may need to un-mount everything before the array can be stopped.  just an advisory so you don't panic.

 

Just type

umount /var/ftproot/disk2

etc...

 

 

Here's the output of mount when this is all set up:

/dev/md2 on /mnt/disk2 type reiserfs (rw,noatime,nodiratime,noacl,nouser_xattr)
/mnt/disk2 on /var/ftproot/disk2 type none (rw,bind)

Upon stopping the array, emhttp issues this command:

umount /mnt/disk2

...so I figured, emhttp should take care of the umounting in one pass without a problem.

Turns out, umount does one thing at a time. So yes, there needs to be another umount command.

 

Thanks Joe.

 

  • 2 weeks later...

Hello Friends,

 

I'm trying the following instructions but our users are still able to see all the disk and shares when they login.

Please let me know what I'm doing wrong.

 

This what I'm typing in at the command line. Pressing enter after each line:

 

sleep 30

mkdir -p /var/ftproot/disk1

mkdir -p /var/ftproot/disk2

mkdir -p /var/ftproot/Client Websites

echo 'anon_umask=0022' >> /etc/vsftpd.conf

echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf

mount --bind  /mnt/Client Websites /var/ftproot/Client Websites

 

We only want allow access for users to the "Client Websites" folder

All other files can only be accessed by the root user

 

Does the spacing make a difference when typing in these commands?

 

Thanks again fellow unraiders.

 

Cheers,

 

Hello Friends,

 

I'm trying the following instructions but our users are still able to see all the disk and shares when they login.

Please let me know what I'm doing wrong.

 

This what I'm typing in at the command line. Pressing enter after each line:

 

sleep 30

mkdir -p /var/ftproot/disk1

mkdir -p /var/ftproot/disk2

mkdir -p /var/ftproot/Client Websites

echo 'anon_umask=0022' >> /etc/vsftpd.conf

echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf

mount --bind  /mnt/Client Websites /var/ftproot/Client Websites

 

We only want allow access for users to the "Client Websites" folder

All other files can only be accessed by the root user

 

Does the spacing make a difference when typing in these commands?

 

Thanks again fellow unraiders.

 

Cheers,

 

 

You have a space in the folder name Client Websites.  Don't 'mkdir' or 'mount' yell at you when you try that?

Either enclose the 'path/name' in single quotes, or use underscore, like Client_Websites

Also, if you only want the client websites folder, then why did you bother creating  /var/ftproot/disk1 and /var/ftproot/disk2?

 

If nothing else helps, running sleep 30 ten times in a row should fix the problem.   ;)   Or any other problem.

 

And BTW, typing all that in at the command line, as you're doing, will not survive server reboot.  

If you want the changes to be permanent you need to put that in your 'go' script.

Thanks Purko! Your suggestions and advice is always appreciated.

Again apologize for my noviceness, but I'm learning.

 

You have a space in the folder name Client Websites.  Don't 'mkdir' or 'mount' yell at you when you try that?

No it went through fine, however i'm pretty sure you're right and i should be getting yelled at by someone  ::)

 

Also, if you only want the client websites folder, then why did you bother creating  /var/ftproot/disk1 and /var/ftproot/disk2?

The disk1 and disk2 was already created when I setup the unraid box. It just appeared. I dont know how to get ride of it. Just created user shares and added security according to the manual.

 

Last Questions, what is "Go" Script.

 

Thanks again,

 

The disk1 and disk2 was already created when I setup the unraid box.

 

Those disk1 and disk2 that were already created, those are disk shares over the samba protocol. 

In this thread we are talking about setting up service over the ftp protocol.

Are you sure you're posting in the right place?

 

Last Questions, what is "Go" Script.

 

The 'go' script is located in the config folder on your flash disk.  It gets executed every time the server boots.

 

Hello,

 

Answers to your response..

 

Those disk1 and disk2 that were already created, those are disk shares over the samba protocol.

In this thread we are talking about setting up service over the ftp protocol.

Are you sure you're posting in the right place

 

A: when i setup the server i stuck 3 hard drives in there then booted it up. 1 1tb, 1 750gb, 1 500gb. When i booted it up it showed disk1 and disk2. They are not shares they are just the two hard that showed up.

 

When I go to the shares settings i don't see Disk1 or Disk2. I just see the top level folders shares.

 

How would i get rid of disk1 and disk2 if they are not shares but the actual disk?

Or if I just run the command it will take care of it.

 

Because right now when anyone logins via FTP is shows Disk1, Disk2, and All Folders Shares.

Just want people to only view Client Website folders and not any other folder, tried doing the exclude option in the shares but that doesn't work.

 

Thanks again for continued help.

 

Cheers

 

 

Because right now when anyone logins via FTP is shows Disk1, Disk2, and All Folders Shares.

Yes, that's how it's out-of-the-box: the ftp-root is "/mnt/" so ftp client sees everything mounted there -- all your disk shares.

If you follow correctly the steps in my original post, we change the ftp-root with this command:

echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf

So now the ftp clients will only see whatever you put under "/var/ftproot/"

 

  • 2 weeks later...

Thanks Purko,

 

Ok so to be clear here, in the go script I would add the following commands for my setup

 

sleep 30

mkdir -p /var/ftproot/disk1

mkdir -p /var/ftproot/disk2

mkdir -p /var/ftproot/clientwebsites

echo 'anon_umask=0022' >> /etc/vsftpd.conf

echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf

mount --bind  /mnt/disk2 /var/ftproot/disk1

mount --bind  /mnt/disk4 /var/ftproot/disk2

mount --bind  /mnt/disk6/Music /var/ftproot/clientwebsites

 

This will make it so user will only be able to see the "clientwebsites" folder correct?

And the super admin (root) will be able to access all folders when FTPing to the server.

 

Thanks Again

 

 

This will make it so user will only be able to see the "clientwebsites" folder correct?

No.  You did 'local_root=/var/ftproot' so the FTP clients will see anything that's under '/var/ftproot/'

I see that you put three things under '/var/ftproot/' -- disk1, disk2, and clientwebsites.  The FTP clients will see all that.

I already asked you before, why are you puting disk1 and disk2 there if you don't want to share them over FTP?

 

I see what you mean now, So I run the script on the folder that I want to make accessible only to the users.

All other will be hidden after I these commands. So I guess the new command would be.

 

sleep 30

mkdir -p /var/ftproot/clientwebsites

echo 'anon_umask=0022' >> /etc/vsftpd.conf

echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf

mount --bind  /mnt/disk6/Music /var/ftproot/clientwebsites

 

Correct?

 

Quick questions how they have accessibility options in the shares settings and when I set it, it doesn't work instead I have to use this magical script method.

 

Thanks Again!

Ok I just added the following to my go script

 

Did the following

 

Open up the "go" file in windows with text editor "crimson editor" and then pasted in the following

 

sleep 30

mkdir -p /var/ftproot/clientwebsites

echo 'anon_umask=0022' >> /etc/vsftpd.conf

echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf

mount --bind  /mnt/user/clientwebsites /var/ftproot/clientwebsites

 

Did a reboot, everything is working as. Users can only see the folder "clientwebsites"

But now here the problem.

 

The Root User can't access the other files. When logging in with "Root" (super admin) user I can't access the other folders, disk and files. Please advise.

 

Thanks again for all the help.

 

Thank

http://vsftpd.beasts.org/

http://vsftpd.beasts.org/vsftpd_conf.html

user_config_dir

    This powerful option allows the override of any config option specified in the manual page, on a per-user basis. Usage is simple, and is best illustrated with an example. If you set user_config_dir to be /etc/vsftpd_user_conf and then log on as the user "chris", then vsftpd will apply the settings in the file /etc/vsftpd_user_conf/chris for the duration of the session. The format of this file is as detailed in this manual page!

 

Thanks purko,

 

Was reading through it, and I'm a bit lost.

Do I just download the vsftpd-2.3.0pre2.tar.gz and copy all the files to the flash drive

 

After that what commands do I run to get it working?

Again I'm learning here, so thank for the continued help.

 

Cheers!

Do I just download the vsftpd-2.3.0pre2.tar.gz and copy all the files to the flash drive

Why would you want to do that?  Vsftpd is already installed and running on unRAID. 

http://vsftpd.beasts.org/vsftpd_conf.html  is the manual for the config options.

 

`echo something >> /etc/vsftpd.conf`  is just a quick way to append a line to vsftpd.conf.

But if you need to do some serious editing of vsftpd.conf, then you better make a copy of it to the flash disk, and back link it to /etc/

Here is how you can do that.  Telnet to the server and type this:

mkdir -p /boot/custom/etc
cp  /etc/vsftpd.conf  /boot/custom/etc/vsftpd.conf
ln -sf /boot/custom/etc/vsftpd.conf /etc/vsftpd.conf

Add this to your 'go' script:

ln -sf /boot/custom/etc/vsftpd.conf /etc/vsftpd.conf

Now you can edit  /boot/custom/etc/vsftpd.conf  to your heart's content, and all your changes will survive server reboots.

( /boot/custom/etc/vsftpd.conf  will be on your flash disk). 

 

When editing that file, keep in mind this:

http://lime-technology.com/wiki/index.php?title=FAQ#Why_do_my_scripts_have_problems_with_end-of-lines.3F

 

 

Thanks Purko for your advice,

 

Course I have more questions  ;D

 

So I now add this to my go script:

 

mkdir -p /boot/custom/etc

cp  /etc/vsftpd.conf  /boot/custom/etc/vsftpd.conf

ln -sf /boot/custom/etc/vsftpd.conf /etc/vsftpd.conf

 

After I do that do I just go to the flash drive and edit the vsftpd.conf file? and add lines of code to it?

 

After reading through the link you provided for the config options, I'm lost.

What commands lines would i put in the vsftpd.conf file to make it so that only the Root users can see all files.

 

Thanks again.

So I now add this to my go script:

mkdir -p /boot/custom/etc

...

No, you don't!  You do that from a telnet session, one time only.  Please read carefully.

In the 'go' script you only add one line -- the one that links your persistent config to the config that's used by vsftpd.

 

After I do that do I just go to the flash drive and edit the vsftpd.conf file? and add lines of code to it?

Yes.

 

mkdir -p /boot/custom/etc

cp  /etc/vsftpd.conf  /boot/custom/etc/vsftpd.conf

ln -sf /boot/custom/etc/vsftpd.conf /etc/vsftpd.conf

 

Do this once, and one time only:

 

mkdir -p /boot/custom/etc
cp /etc/vsftpd.conf /boot/custom/etc/vsftpd.conf

 

Put this in your go file:

 

rm /etc/vsftpd.conf
ln -s /boot/custom/etc/vsftpd.conf /etc/vsftpd.conf

 

The way you had it setup, you would always overwrite your modified file with the stock base file on every single boot.

Put this in your go file:

rm /etc/vsftpd.conf
ln -s /boot/custom/etc/vsftpd.conf /etc/vsftpd.conf

That "rm" line is not really needed if you're using the ln command with the -f option.

 

The only line that needs to be in the 'go' script is this:

ln -sf /boot/custom/etc/vsftpd.conf /etc/vsftpd.conf

(as posted 4 posts earlier)

 

And, don't skip this same line in your initial one-time setup, if you want the change to take effect immediately, without the need to reboot your server.

(also posted 4 posts earlier)

 

Great thanks for the advice everyone.

 

After i run those commands.

 

What commands do i put into my vsftpd.conf to make it so the root gets full access to all the folders.

 

Sorry, I read through all the commands and did some research on google, but I dont know how to put them all together.

However points to you guys and the forum as I'm learning a lot :)

 

Cheers,

  • 1 year later...

I have been able to get VSFTP working with a user and login I created in unraid. 

However when a user logs in to the server via FTP - they can see every single disk share. 

How can I create it so that when a user logs in - they are directed to or only see one specific directory?

 

Let's say for example that you want to share the following things over ftp:

1. Disks 2 and 4, but not any other disks.

2. Folder "Music" which you have on disk 6.

3. User share "Stuff" which you've created with the unRAID's web interface.

 

My first thought was to just redirect the vsFTPd's local_root to a new empty directory,

and then use symbolic links for the things that we want to share.  Unfortunately, that won't work.

The thing is, sFTPd doesn’t allow browsing symbolic link targets when their target is outside the user’s chroot.

So, the mount command comes to the resque.  ;)

 

Here's your solution.  Put the following commands at the end of your 'go' script:

sleep 30
mkdir -p /var/ftproot/disk2
mkdir -p /var/ftproot/disk4
mkdir -p /var/ftproot/Music
mkdir -p /var/ftproot/Stuff
echo 'anon_umask=0022' >> /etc/vsftpd.conf
echo 'local_root=/var/ftproot' >> /etc/vsftpd.conf
mount --bind  /mnt/disk2        /var/ftproot/disk2
mount --bind  /mnt/disk4        /var/ftproot/disk4
mount --bind  /mnt/disk6/Music  /var/ftproot/Music
mount --bind  /mnt/user/Stuff   /var/ftproot/Stuff

 

Enjoy!

I'm just getting around to playing with the ftp server. Does the information in this thread still apply to version5 betas?

 

Instead of putting all those commands above in the go script, can I put them in external .sh file that I can execute from the go script? That way I can just make changes to the external file without editing the go script each time I want to make a change to what is mounted or not.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.