LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-02-2013, 08:25 AM   #1
ivanmacx
Member
 
Registered: Apr 2006
Location: Cambridge, UK
Distribution: Ubuntu Jaunty
Posts: 45

Rep: Reputation: 16
Read only SFTP by user


Is it possible to set up sftp users with varying permissions on the same filesystem. I have successfully set up an sftp system (on Amazon EC2) using OpenSSH on Debian (OpenSSH_5.5p1 Debian-6+squeeze2) and chrooting different groups of users to different directories. All works fine and people can log in and upload and download as required.

I have a new user I want to add, accessing the same files as the other users, but with read-only access and I can't find any way to do that.

Is there any way to set access permissions by user?

If not can anyone suggest a workaround (eg. readonly --bind mount which I can't quite work out how to do) to achieve what I'm after?

Thanks.
 
Old 03-03-2013, 10:51 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try Match User ...
http://www.openbsd.org/cgi-bin/man.c...nfig&sektion=5
http://security.stackexchange.com/qu...methods-in-ssh
 
Old 03-05-2013, 03:15 AM   #3
ivanmacx
Member
 
Registered: Apr 2006
Location: Cambridge, UK
Distribution: Ubuntu Jaunty
Posts: 45

Original Poster
Rep: Reputation: 16
Thanks. Yes, I can match user but I don't know how to then set read only permissions for those users. Any idea?
 
Old 03-05-2013, 08:34 AM   #4
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Why not change the permissions of the home directory an all child directories to something like...
Code:
chmod 774 /home/sharedhome

#propagate to all directories
find /home/shardhome -type d -exec chmod 774 {} \;
chmod 700 /home/sharedhome/.ssh
Then any users which are part of the group for that folder has rwx access. Make sure that your readonly user isn't the owner and not in a group with rwx. Then that user will only have read permission.
 
Old 03-06-2013, 04:38 PM   #5
ivanmacx
Member
 
Registered: Apr 2006
Location: Cambridge, UK
Distribution: Ubuntu Jaunty
Posts: 45

Original Poster
Rep: Reputation: 16
Unfortunately what I need is that the same set of directories are read/write for a group of users (eg. 5 people) and read only for another 3 users, and no access for anyone outside those groups. I don't think I can achieve that with group permissions.

The only route I see at present is to set up a readonly directory and do a readonly --bind mount of the relevant directories within that folder, and then chroot the read only users to that directory. I guess that's the only solution.

Last edited by ivanmacx; 03-06-2013 at 04:39 PM.
 
Old 03-06-2013, 06:43 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
How about setting up rw users as a group, then ro users as ro via ACLs?
 
Old 03-08-2013, 05:32 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,310
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
sftp-server

The sftp subsystem can be set to be read only using -R. See the man page for sftp-server(8) Match won't allow specifying a subsystem, so the change has to be done another way. One way would be to have two ssh systems running on the same machine but on different ports. One would be set to allow only the members of the read-write group to log in. The other would allow everyone to log in, but would put the sftp subsystem into read-only mode.
 
Old 03-09-2013, 03:03 PM   #8
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
PAM with SELinux could be used for this issue. Though SELinux isn't on Ubuntu by default so you'd either have to change that or see if there's an apparmor equivalent configuration with PAM. SELinux could be used to enforce the users ability on the system and PAM can determine whether or not they're allowed to log in. For example PAM can be configured that if SELinux is set to permissive they're not allowed in but when it's enforcing they are.
 
  


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
Unable to SFTP with a user made for only to perform SFTP raj2arora2009 Linux - Security 1 04-10-2012 07:23 AM
how to create sftp user only in red hat 4 not ftp user ..only sftp user princeu28 Linux - Newbie 1 10-14-2008 08:10 AM
User Creationg : ssh/sftp user jail to $HOME only routers Solaris / OpenSolaris 2 10-29-2007 11:28 PM
let a user only connect via sftp FORESTHUS Linux - Security 7 01-16-2004 10:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:51 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