I prefer to create a user group sftp
and restrict users in that group to their home directory.
First, edit your /etc/ssh/sshd_config
file and add this at the bottom.
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
This tells OpenSSH that all users in the sftp group are to be chrooted to their home directory (which %h
represents in the ChrootDirectory command)
Add a new sftp group, add your user to the group, restrict him from ssh access and define his home directory.
groupadd sftp
usermod username -g sftp
usermod username -s /bin/false
usermod username -d /home/username
Restart ssh:
sudo service ssh restart
If you are still experiencing problems, check that the directory permissions are correct on the home directory. Adjust the 755 value appropriately for your setup.
sudo chmod 755 /home/username
EDIT: Based on the details of your question, it looks like you are just missing the sshd_config portion. In your case, substitute sftp
with sftpexport
. Also be sure that the file permissions are accessible on the /u02/export/cdrs
directory.
An even better setup (and there are even better setups than what I am about to propose) is to symlink the /u02/export/cdrs
directory to the user home directory.
useradd
command? (without having to create a new user group) – Rexer