Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

You need to change what folder the user 'test1' arrives at with SSH. Look at the answer to this question: http://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

share|improve this answer
    
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 at 13:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.