well, i'm not sure it's important to make it required, but:
If you want to know how to do something cool:
if you build openssh with chroot support (it comes with it in most distros, but if you rebuild to apply the patch you may have to add the proper flag) you can create a chrooted SFTP server just by using the sshd_config file.
basically, what i do is this: I create some users for running rtorrent. These users are NOT the same username i intend to give my users, but an internal "system only" user just for running rtorrent
i normally create them with uid's and names like
rtuser1 uid 5001 scgi port 5001 with these dirs /home/rtuser1/.session /home/rtuser1/rtorrent/download /home/rtuser1/rtorrent/watch
rtuser2 uid 5002 scgi port 5002 with these dirs /home/rtuser2/.session /home/rtuser2/rtorrent/download /home/rtuser2/rtorrent/watch
rtuser3 uid 5003 scgi port 5003 with these dirs /home/rtuser3/.session /home/rtuser3/rtorrent/download /home/rtuser3/rtorrent/watch
so on and so forth
then, i create some MORE unix users with the SAME uid as these users (using the -o switch) These names will be the user name i intend to use for the webuser, ftp and sftp I create them WITHOUT home dir's. On FreeBSD the commands are something like this:
Code:
pw useradd SomeUSER1 -u 5001 -g 5001 -d /nonexistent -s /bin/sh -o
pw useradd SomeUSER2 -u 5002 -g 5002 -d /nonexistent -s /bin/sh -o
pw useradd SomeUSER3 -u 5003 -g 5003 -d /nonexistent -s /bin/sh -o
then, of course, set the unix password wiht passwd SomeUSER1
On Linux, the command is something like:
Code:
useradd -u 5001 -g 5001 -o -s /bin/sh -d /nonexistent SomeUSER1
useradd -u 5002 -g 5002 -o -s /bin/sh -d /nonexistent SomeUSER2
useradd -u 5003 -g 5003 -o -s /bin/sh -d /nonexistent SomeUSER3
now, i create a dir for the chroot, maybe something liek
Code:
mkdir /opt/sftp
mkdir -p /opt/sftp/SomeUSER1/torrents
mkdir -p /opt/sftp/SomeUSER2/torrents
mkdir -p /opt/sftp/SomeUSER3/torrents
then, i'll use bind or nullfs (depending on os) to mount the users download dir on the torrents dir i just made (note: the reason i don't just mount the download dir on /opt/sftp/SomeUSER1 is because this dir MUST be owned by root in order for this chroot to work correctly)
so, for freebsd, you'd add something like this to your /etc/fstab:
Code:
/home/rtuser1/rtorrent /opt/sftp/SomeUSER1/torrents nullfs rw 0 0
/home/rtuser2/rtorrent /opt/sftp/SomeUSER2/torrents nullfs rw 0 0
/home/rtuser3/rtorrent /opt/sftp/SomeUSER3/torrents nullfs rw 0 0
for linux, it's something like this:
Code:
/home/rtuser1/rtorrent /opt/sftp/SomeUSER1/torrents bind bind,defaults 0 0
/home/rtuser2/rtorrent /opt/sftp/SomeUSER2/torrents bind bind,defaults 0 0
/home/rtuser3/rtorrent /opt/sftp/SomeUSER3/torrents bind bind,defaults 0 0
in your sshd_config file (normally at /etc/ssh/sshd_config ) look for the Subsystem sftp line, if it's set to something like this:
Code:
Subsystem sftp /usr/libexec/sftp-server
change it to this:
Code:
Subsystem sftp internal-sftpnow, you just need to add the proper directives to your ssh config, something like this:
Code:
Match User SomeUSER1,SomeUSER2,SomeUSER3
ChrootDirectory /opt/sftp/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
and if you did everything right, you'll have an sftp user who has read/write privelages but is chrooted ONLY to the dir's for your rtorrent files.
another thing i tend to do when i do this, is:
I do not set a password at all for the users running rtorrent. Instead, i set a secure ssh key.
Another thing you can do, if you wish, is build a SEPARATE ssh server for sftp. This way you run it on a different port, with it's own settings.