LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 06-24-2015, 11:32 AM   #1
Slicster
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Rep: Reputation: Disabled
SFTP access to only one folder


Hi Guys,
I've searched through the web and forums before posting and yes I have found some sites that show how to create SFTP access on Redhat. What I'm trying to accomplish is to create a new user called DEV that has it's home folder set to "/var/www/web/media/nutritionalfacts" and cannot browse anywhere else. These are the inscrutctions I've tried without success...

Code:
groupadd  sftp_users
useradd  -G sftp_users  -s /sbin/nologin  DEV -d /var/www/web/media/nutritionalfacts
passwd DEV

# vi /etc/ssh/sshd_config
#comment out the below line and add a line like below
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp

# add Below lines  at the end of file
Match Group sftp_users
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory h
ForceCommand internal-sftp

service sshd restart

chmod 755 /var/www/web/media/nutritionalfacts
chown root /var/www/web/media/nutritionalfacts
chgrp -R sftp_users /var/www/web/media/nutritionalfacts
For whatever reason, the above doesn't work and I can't connect via SFTP with the new user. In the meantime, I simply did the following which works but allows the user to browse through the whole Redhat OS filesystem...

Code:
useradd DEV -M -d /var/www/web/media/nutritionalfacts -s /sbin/nologin
passwd DEV
I really want the user to be restricted to only that folder via SFTP and for it to be as simple as possible.

Anyone?

Last edited by Slicster; 06-24-2015 at 11:56 AM.
 
Old 06-25-2015, 01:39 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
We typically use scponly for this:
http://sourceforge.net/projects/scponly/files/
It lets you setup a jailed user for doing scp/sftp and prevents use of ssh for that user.
 
Old 06-28-2015, 07:12 AM   #3
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 354

Rep: Reputation: 51
Try to make "/usr/libexec/openssh/sftp-server" as user shell, not "/sbin/nologin".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem while accessing folder using SFTP from other server agkagk AIX 2 03-30-2015 03:08 PM
How to create a user and limit him to one folder only using sftp? ASTRAPI Linux - Security 4 01-01-2015 04:28 AM
make multiple folder on samba linux & each folder can be access each person only Aneesh.T .S Linux - Server 1 01-31-2013 06:01 PM
SFTP Jailing Two user groups at the same folder neopandid Linux - Server 1 10-10-2012 01:43 PM
shared folder permissions for SFTP jawilson Linux - Networking 1 07-07-2005 02:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 09:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration