How to change SFTP default directory
With proftpd you can change the default directory editing /etc/proftpd.conf
DefaultRoot ~
change to
DefaultRoot ~/music
How i can achieve the same result with SFTP?
Im using ubuntu lucid btw.
Ty so much for your help.
Have a look at this article which shows how to use sshd's ChrootDirectory
to force all members of a particular group into a common directory root. You may be able to modify it to meet your requirements.
Unfortunately I don't have enough reputation to comment because all I wanted to do is stress how important the comment by Richard Fairhurst is and how it should be added to the "official answer". I have seen people here and elsewhere having trouble setting the user home directory or having the user home directory as a "default directory". That's just because in a chroot environment the root directory is not the / any more. Meaning any other path should be relative to the new root path. Ex:
if you chroot to /home and want the default directory to be /home/default you should set the user home directory to /default. Not /home because /home will be the new /.
If you really need to keep the user home directory in /home/user but wish to have a default directory for sftp sessions, you can use the -d parameter for internal-sftp. Like in this example:
Subsystem sftp internal-sftp
Match Group sftpusers
ChrootDirectory /mnt/sftp
ForceCommand internal-sftp -d /default
/default being a directory inside /mnt/sftp. Notice that path here is again relative to the new root.