[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Chroot SFTP not workng in Ubuntu

Posted on 2013-05-20
6
Medium Priority
?
921 Views
Last Modified: 2013-05-20
Guys,

I'm facing a weird problem while trying to setup Chroot SFTP on ubuntu server. SSH is getting crashed whenever I am trying to setup Chroot SFTP. Logs are not showing any error. The only error in logs was related to LOCALE environment and I had fixed now. This error does not seem to be related to chroot. In short I'm clueless. I had tried the following steps.

1. Created new user for SFTP
2. Commented the existing "Subsystem sftp" and added the following.

Subsystem sftp internal-sftp

3. Added the following lines for user.

Match User sftpuser
    ChrootDirectory /home
    AllowTCPForwarding no
    X11Forwarding no
    ForceCommand internal-sftp

4, Set permissions for sftp directory to root.user
5. Restarted ssh and its down.

I had tried commenting the "UserPam" in ssh config as well. This is the same for ubuntu 11 and ubuntu 12. Can anyone share some ideas?

Regards,
Asv.
0
Comment
Question by:LinuxGuru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1600 total points
ID: 39180405
Run sshd this way, to find out which part of sshd_config it doesn't like:

sudo /usr/sbin/sshd -D

sshd will stay in the foreground, so you can watch its messages.

Are you aware that "ChrootDirectory" is always relative to the user's HOME?

So if the HOME directory is /home/users the chroot directory is "/home/users/home", and
thus all components of /home/users/home must be root owned directories that are not writable by any other user or group.
0
 
LVL 13

Author Comment

by:LinuxGuru
ID: 39180499
Hi,

Thanks.

Yes I'm aware that chroot is relative to users home directory.

I will try sudo /usr/sbin/sshd -D and let you know.

Thank you.
0
 
LVL 13

Author Comment

by:LinuxGuru
ID: 39180611
Hi,

Thanks man.

Just to let you know that I have fixed it by

/usr/sbin/sshd -D

UsePam was the culprit. I had to disable it and sftp is working fine as expected.

I had tried by changing UsePam yes and no earlier. But not sure it didnt work.

Also now one more question,

I had set chroot for a user. So I have the users file in some other partition say

Exact user home is /home/user

Some files at /var/files/user and this is owned by user. I have setup a symlink to /var/files/user under /home/user. Any way to make this symlink work when we use chroot in sftp ?

Thanks!
0
Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39180683
No way. Please remember that "chroot" is meant for jailing users in their homes.

Allowing symlinks to the outside of the jail would heaviliy contradict this intention.

Symlinks as set up by you are relative to the system root ( / ), but chroot establishes a new root, thus making the system root inaccessible - that's how it should work.

You could add a whole directory structure to the jail by means of "mount --bind":

mkdir /home/user/files
mount --bind /var/files/user /home/user/files

(just an example!)
0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 400 total points
ID: 39180699
Chroot directory for SFTP needs to be read-only for anyone not root.
After it cd-s to full homedir path in that chroot

say you might need
cd /home
ln -s / home

to make normal users work
0
 
LVL 13

Author Closing Comment

by:LinuxGuru
ID: 39181366
thanks for the assist..
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question