I'm setting up on my VPS a vsftpd, and i don't want users be allowed to leave they're ftp home directory. I'm using local_user ftp, not anonymous, so I added:
chroot_local_user=YES
I've read in a lot of forum post, that this is unsecure.
- Why is this unsecure?
- If this is unsecure because of using ssh to join to my VPS as well, then I could just lock out these users from sshd, right?
- Is there an other option for achiving this behaviour of vsftpd? ( I dont want to remove read permissions on all folder/files for "world" on my system )
Check here for VSFTPD's FAQ for the answer your looking for. Below is the important excerpt that I think will answer your question.
The problem is that you can't both use local accounts and also disable those accounts from shell login. If you set their login shell to /bin/nologin, it won't let you login with vsftpd either.
A better and more secure FTP daemon would be Pure-ftpd. Look it up, it's available from the EPEL repository, and it allows to create virtual users. The server uses a common user/group to set all permissions for the home folders of the users and "maps" the virtual users to that user when it logs in to deal with permissions. That's more secure, and you don't have to deal with openssh login security.
Pure-ftpd also supports a whole lot of features such as quotas, ratios, and such. Much better than vsftpd.
Here's a simple tutorial on how to install it and configure a basic virtual user: http://blog.namran.net/2011/05/04/how-to-setup-virtual-ftp-server-using-pure-ftpd-in-centos/
If you read the full doc (which you should) you'll know that the -d switch when creating the virtual user is an auto-chroot to that directory for that user.
When chroot’ed to
/some/dir/
, the filesystem becomes effectively confined to that directory. Thus, any program attempting to open/etc/some_file
effectively opens/some/dir/etc/some_file
.When
/some/dir/
is writable, a malicious user can insert a maliciously crafted/some/dir/etc/some_file
into it.The resulting degree of insecurity depends on the underlying software being aware of chroot’ing or not.
vsFTPd
surely is (as mentioned in the FAQ above), but some library underneath may not.