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.

Castaglia
  • 3,349
  • 3
  • 21
  • 42
Mike J
  • 170
  • 1
  • 5

2 Answers2

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.

Castaglia
  • 3,349
  • 3
  • 21
  • 42
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

user16081-JoeT
  • 1,948
  • 11
  • 18
  • 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: http://askubuntu.com/questions/121073/why-bash-profile-is-not-getting-sourced-when-opening-a-terminal – Mike J Jan 30 '14 at 13:58