tags:

views:

1992

answers:

5

Hiya,

I need to give SFTP access to a directory within my webroot on my server. I've set up ben_files as a user and have set his home directory to

/var/www/vhosts/mydomain.com/files

That's all fine if he connects with plain old FTP - he's restricted just to that directory, but to enable SFTP i had to add him to bin/bash shell, which suddenly opens up my entire server...

Is there a way of giving him SFTP access but without opening up all my directories? I'd really like him restricted to only his home ;)

Thanks!

+1  A: 

serverfault.com might be a better place to ask?

Dean J
Serverfault is the logical place, but in my experience it's rare to get useful answers there :(
hfidgen
+2  A: 

You might try setting his shell to /bin/rbash

RESTRICTED SHELL If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the following are disallowed or not performed:

   ·      changing directories with cd

plus more...

Make sure you fully understand what is allowed and disallowed before you use this.

Dennis Williamson
rbash is in the distro, but it doesnt appear to allow sftp - i'll have to look into the configuration i guess. Thanks for the tip tho!
hfidgen
+1  A: 

Take a look at rssh. It may already be packaged for your o/s distribution.

Ned Deily
It's not packaged, but that is perfect! I'll look at getting that installed asap ;) Thanks!
hfidgen
+5  A: 
ephemient
Great - this looks likely! The only hitch is that i simply cannot find the service file to restart it :P
hfidgen
Hiya, I get some errors - Starting sshd: /etc/ssh/sshd_config: line 113: Bad configuration option: Match AND /etc/ssh/sshd_config: line 115: Bad configuration option: ForceCommand. These both stop sshd coming back up again. Any ideas?
hfidgen
You probably don't have a new enough SSH version.
ephemient
ahh yeah, i missed that bit in your answer - we're on 4.3, i'll look at getting that upgraded.
hfidgen
Oh wow, 4.3 is 4 years old by now; you're still using it? Upgrade! 5.3 is the current latest release.
ephemient
That's plesk for you... They package up all sorts of old versions with custom tweaks. Hate it tbh.
hfidgen
A: 

Use pam_chroot.

Here is a good manual: http://www.howtoforge.com/chroot%5Fssh%5Fsftp%5Fdebian%5Fetch

rvs