LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-22-2005, 03:25 AM   #1
jefffq
LQ Newbie
 
Registered: Apr 2005
Location: Canada
Posts: 11

Rep: Reputation: 0
Sftp


So I'm trying to setup a secure FTP server. I'm not really sure what the standard setup/procedure is for this. It seems to me that the Linux file permissions are quite difficult to setup in a way that prevents logged on users from browsing around and reading things that maybe they shouldn't. I'd like to have a clean and simple environment for the users, where they just see what they need to, and nothing else. I tried to chroot them to their homes, but then found that symlinks can't get you outside either. I have areas of my filesystem that I want them to have access to, that would be unsuitable to, and far to large for, an ftp user's home directory. So all I can think of is to have a regular login to the home, with the symlinks that I want, and to setup strange and annoying file permissions all over my filesystem. Is there some great way to do this that I don't know about?

I'm also curious about the encryption. As I understand it, using SFTP through SSH encrypts everything, including the data transferred. This is what I want. However, I was reading some documentation for PureFTPd, and it mentioned that it only encrypted the logins and commands, not the data. I'm wondering if this is a universal difference between SSH and the regular FTP daemons with SSL/TLS support.

Finally, I'd just like to know what the most common procedures are for this, and what servers are recommended.

Thank you in advance,
jef
 
Old 06-22-2005, 04:53 AM   #2
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
SFTP: ftp over ssh, everything is encrypted
FTPS or FTP/ssl:ftp over ssl, the control connection is encrypted. The data connections are not always encrypted. Check your server documentation.

If you have openssh, sftp probably already works, give it a try.
Most ftp servers allow you to jail a user in his home directory. Check your server documentation. I don't think Openssh/SFTP can do this, as the user must have an account with ssh shell access anyways, which can't really be jailed. It would be pointless to restrict him in sftp mode and let him see the files in ssh.
 
Old 06-22-2005, 02:13 PM   #3
jefffq
LQ Newbie
 
Registered: Apr 2005
Location: Canada
Posts: 11

Original Poster
Rep: Reputation: 0
Alright, so not all FTPS servers encrypt the data. Good to know, I'll have to make sure of that, then. Or I'll just use SSH.

SFTP does work over SSH. My problem is what to do now. I did set it up so the user was chrooted to their home directory (jailed, as you say). It was a lot of work, just to find out that this won't work for me. You have to put the essential shell environment files in their home directory, basically. But you also need a specially compiled, and patched, SSH for it to work properly.

As I mentioned in my first post, I don't want to chroot (jail) the users to their home. I have some areas of my filesystem, that are very large, that I don't want residing in that user's home directory. I was hoping that symlinks could get them out of their homes, just to these specific folders, but they can't.

I'd like to know how people setup their ftp servers, if they don't chroot users to their homes. It just doesn't seem right for ftp users to have the ability to peruse your entire filesystem. Chroot can't be the only way to prevent this. Even IIS has a simple mechanism for virtual hosts that link to a specific folder and don't allow users outside of it. The only way that I can think of, to mimic this in linux, would be to have a user for each one of these folders, and to make those folders their home directories. That's just silly. :P

Last edited by jefffq; 06-22-2005 at 02:16 PM.
 
Old 06-22-2005, 03:00 PM   #4
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
For obvious reasons, you can't leave a chroot. proftpd gives you some suggestions:
Quote:
Symlinks will not work from within a chrooted area. The reason should be clear from a casual inspection of the nature of the chroot command. It is not possible to have a symbolic link to a directory which can"t be reached beacuse it's outside of the current chroot. Work arounds to allow access to other parts of the file system include exporting the part of the filesystem to be accessed from inside the chroot and mounting via NFS, using hard file links or (on Solaris) using lofs to mount the directory via the loopback.

mount -Flofs /home/data1 /ftp/data1
mount -Flofs /home/data2 /ftp/data2


As of the 2.4.x Linux kernel tree it is possible to mount filesystems multiple times and to mount subdirectories of filesystems elsewhere on the filesystem.
Pureftpd has a virtual chroot mode to follow symlinks http://www.pureftpd.org/
 
Old 06-23-2005, 01:51 AM   #5
jefffq
LQ Newbie
 
Registered: Apr 2005
Location: Canada
Posts: 11

Original Poster
Rep: Reputation: 0
That 'mount -Flofs' would be perfect! If it worked for me
It's telling me that the first directory is not a block device.

That virtual chroot that allows symlinks would also be neat. But pureftpd is the one where the docs said it didn't encrypt the data .

I'd like to get that fancy mounting thing to work. I'll have to look into that.

Thanks for the advice.
 
Old 06-23-2005, 04:41 AM   #6
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
man mount:

Since Linux 2.4.0 it is possible to remount part of the file hierarchy
somewhere else. The call is
mount --bind olddir newdir
After this call the same contents is accessible in two places.
 
Old 06-28-2005, 12:55 PM   #7
jefffq
LQ Newbie
 
Registered: Apr 2005
Location: Canada
Posts: 11

Original Poster
Rep: Reputation: 0
Omg, thank you Stefan. That worked for me, and will be perfect. I was just coming back here to see what the arguments were for the "Flofs" one so I could get on with troubleshooting why it wasn't working for me. Now I don't have to, thank you.
 
Old 06-29-2005, 02:27 AM   #8
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
The Flofs one was for Solaris.

Be careful: with too many users, I think you can run out of mountable filesystems (I think you can only have 255 mounted filesystems or something like that), but I am not sure.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 09:14 PM
Sftp mitchb Linux - Newbie 4 08-25-2004 06:00 AM
Sftp mr_a_ali Linux - General 1 08-18-2004 01:28 PM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 10:29 AM
sftp rafalek *BSD 2 12-11-2003 06:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration