1

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.

2 Answers 2

1

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.

0

You need to change what folder the user 'test1' arrives at with SSH. Look at the answer to this question: https://stackoverflow.com/questions/3530433/putty-change-default-ssh-login-directory;
Add cd subdir/subdir to ~/.bashrc or ~/.bash_profile, or
change the home directory of the user.

To change a user's home directory: usermod -d /path/to/dir/ username

1
  • I tried both files and neither worked for me. Perhaps I've done something incorrect? I added cd ftproot (to change into /home/test1/ftproot). I also tried the full path. I read up on this and I'm wondering if this is applicable: askubuntu.com/questions/121073/…
    – Mike J
    Jan 30, 2014 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .