What's the easiest and standard way to create and restrict a new user to /var/www/ in CentOS ?
Edit: Ideally restricted to SCP only.
What's the easiest and standard way to create and restrict a new user to /var/www/ in CentOS ?
Edit: Ideally restricted to SCP only.
With a recent enough CentOS comes a new enough OpenSSH with
chroot
andinternal-sftp
features.First you need to configure OpenSSH to use the internal SFTP. This is done by adding this line to
sshd.conf
:Then you can add rules for restricting users / groups to their home directories:
Or for groups
I am not aware of a "stadard way" but one method to do this is to create a so called "jail" for the user where his/her jail is /var/www. This can be done by creating a chroot jail. See the chroot command. The jail can also control what the user can do in the jail ie which commands/programs can be run.
Based on your reply to my comment, I wouldn't give the user a full shell. This makes the task far easier. There are a few shell replacements that come to mind which can be used to allow the user to manage files and nothing else:
I've personally used scponlyc a few times. It even includes scripts to set up chroot jails for you (github wiki)
My favorite why is installing mysecureshell
http://mysecureshell.sourceforge.net/
It's the most config friendly option. You can do a lot of great things with it