Ubuntu – How to setup ProFTP and SSHD_config to FTP and SFTP to the same directory on Ubuntu 12.04

ftpproftpdsftpUbuntu

I'm having troubles with a chrooted environment on Ubuntu 12.04.

Objective

Set up FTP/SFTP server where users part of a new 'sftp' group can sftp and ftp to the same directory

ProFTP Setup

The ProFTP setup is a base build in Ubuntu and it works as expected. User 'test1' can log into the server via ftp on tcp 21 and is chrooted to his directory /home/test1/ftproot.

in /etc/proftpd/proftpd.conf

# Use this to jail all users in their homes
DefaultRoot                     ~/ftproot

When the user test1 logs in via ftp, he sees only / (that's what I want).

But when the same user logs in via sftp, and it's properly chrooted using sshd_config, because the /home/test1 directory MUST be owned by root, the user logs in via sftp and sees:

/
/ftproot
/.bashrc

What this means is that the user does NOT end up in the same /ftproot directory. test1 will end up in his /home/test1 home directory by default which is actually owned by root. Therefore, he cannot write anything via sftp until he changes directories to /ftproot.

How do i setup the sftp server so by default he ends up in the same directory?

Here are my sshd_config relevant settings:

#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp -f AUTH -1 VERBOSE
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
#AllowTcpForwarding No

ChrootDirectory %h/ftproot does not work.

Best Answer

Now that proftpd has its own SFTP implementation via the mod_sftp module, using that for your SFTP needs (rather than OpenSSH) might neatly address this issue.