I really need some help, I have been trying to jail a user using ubuntu
.
Thing to note:
james
is the usersshusers
is the group/home/james/upload/
is the directory where I wish to lock user
sshd_config:
AllowGroups sshusers
Match Group sshusers
ChrootDirectory /home/%u/upload/
ForceCommand internal-sftp
I followed an answer on askubuntu , here are my commands
sudo chown root /home/james
sudo chmod go-w /home/james
sudo mkdir /home/james/upload
sudo chown james:sshusers /home/james/upload
sudo chmod ug+rwX /home/james/upload
Problem:
I get this error
Error: Network error: Software caused connection abort
Error: Could not connect to server
I investigated in the logs, and I found this:
fatal: bad ownership or modes for chroot directory component "/home/james/upload/"
But if I run the following commands
sudo chown root /home/james/upload
sudo chmod go-w /home/james/upload
It works perfect , user can connect, folder is locked BUT cannot drop files in the directory
Status: Listing directory /
Status: Directory listing successful
Status: Starting upload of C:\Users\Program\AppData\Local\Temp\fz3temp-1\empty_file_yq744zm
Command: put "C:\Users\Program\AppData\Local\Temp\fz3temp-1\empty_file_yq744zm" "test"
Error: /test: open for write: permission denied
Error: File transfer failed
Please advice, I have search google so much all the links are purple now (visited :P
)
I'm using filezilla client to test SFTP
.
ChrootDirectory
is: "After the chroot, sshd(8) changes the working directory to the user's home directory." So say you have/some/dir/chroot/home/james
, and you setChrootDirectory
to/some/dir/chroot
, it will change the directory to the home folder, relative to that:/some/dir/chroot/home/james
. That's probably how those servers do it. – muru Sep 20 '14 at 03:07