AndrijaM wrote:
Melon, thanks, thats exactly what I need to do:
to allow user to log in via SFTP and restrict them into their home directory... (I don't know what chroot/jail is, I need easiest way to make this work )
just don't know how
I installed scponly package. How do I start that script?
And btw setup_chroot.sh is setup_chroot.sh.gz
A chroot or jail environment means that a user or process is restricted to its own directory and cannot see the entire filesystem.
If the setup_chroot.sh script is gzipped, you need to uncompress it first.
Go to the directory where your setup_chroot.sh.gz file is, then run:
Code:
sudo gunzip setup_chroot.sh.gz
If the script is not executable, change permissions (e.g.: sudo chmod 755 setup_chroot.sh)
After that you can run the script via root (sudo ./setup_chroot.sh) which will ask for a username, home directory, name of the writable dir (default is 'incoming') and you can set the password for the new user.
If everything goes fine, your system will have a user that can only login to an scp/sftp enabled shell and cannot change directory outside its home.
You are advised to plan the filesystem layout for your websites, for example:
domain1.com and domain2.com for user 'john':
virtual host roots:
/srv/www/john/domain1.com/public
/srv/www/john/domain2.com/public
john's home is:
/srv/www/john
Then either set the public folders' permissions to something that john is able to write, or change the folder's ownership to john's.
I hope this is clear and simple enough.
One additional note: I usually create a user group named 'sftponly' and put these chrooted users to this group and set this group in sshd_config:
Code:
Match group sftponly
PasswordAuthentication yes
PubkeyAuthentication no
If I want my users to use only key-based logins I switch the the yes/no values in the config above.[/code]