Forum archive
Chroot problem
Hi,
It has been well over 10 years since I've used a linux server and need a simple SFTP server so I downloaded Core and thought I'd give it a try. Installed in a VMware environment and have the server installed.
I want to have a separate disk as a repository for the users and have successfully created that finally. I called it 'data'.
I created a new user and group of the same name and after some fiddling figured out how to get the home directory on this new data disk. Escentially I created a 'data' mounting point and have a 'user1' directory on it which when I log into the server as 'user1' I am there by default and I can create and modify files.
I edited the /etc/ssh/sshd_config file and added the following:
Subsystem sftp internal-sftp
Match Group user1
ChrootDirectory /data
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp
This seems to work except when I SFTP into it as user1 I am at the root of /data directory and I cannot send files to it. So I modified the sshd_config file to add /user to the ChrootDirectory statement.
Now I get an error: Using username: user1
Authentication failed.
Any suggestions? What did I miss?
As root I also set chmod 770 /data/user1 thinking it was a user rights issue.
Thanks in advance,
Linn
To use your example, /data will need to be owned by root (but readable by your user) and inside you will need a sub dir, owned by your user and named after them. E.g. /data/user1.
To avoid user confusion (dropping into a dir that they can read but not write to), you can (re)set the chrooted user's home as /user1. That works because /data is the root (/) of the chroot, therefore within the chroot, /data/user1 appears as /user1.
Hope that helps. :)
Oops, I forgot to mention, you'll need to change the ssh_config and set the home as /data/%u (which will resolve to /data/user1).