LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-02-2020, 09:34 AM   #1
Simpo20
LQ Newbie
 
Registered: Jan 2020
Posts: 2

Rep: Reputation: Disabled
SFTP Server Setup


First time posting, And Relative newbie - We are trying to put together a (what I was hoping to be) simple SFTP server with a top level user and sub 'user root' users (see image)

Image of what we are trying to achieve

(cant post image due to being new, but basically describes a TOP LEVEL user, with USER 1, 2 3 etc.. account with thier own locked down home/roots)

We would love to have some kind of Web Gui to manage but not essential - attempting to build in any recommended linux distro.

We have had this working but the permissions side of things were being inconsistent at best.

Any Help - or directions on where to post appreciated.

Thanks Adrian
 
Old 01-03-2020, 02:05 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,294
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Welcome.

Adding a GUI would only complicate things and just represent the text file anyway.

How many users are you thinking about adding?

What it sounds like you are aiming for is a set of SFTP-only accounts locked into a chroot. The chroot target must be root-owned and writable only by root. There are two ways to do that. One is to nest an extra directory within the users' chroots:

Code:
mkdir /toplevel/; 
chown root:root /toplevel/; 
chmod u=rwx,g=rwx,o=rx /toplevel/;

mkdir -p /toplevel/user/user/; 
chown root:root /toplevel/user/; 
chown user:user /toplevel/user/user/ ; 
chmod u=rwx,g=rwx,o=rx /toplevel/user/;  
chmod u=rwx,g=rwx,o=rx /toplevel/user/user/;
Then the matching stanza in sshd_config could be something like this:

Code:
Match Group sftp-only
        ChrootDirectory /toplevel/%u
        AllowTCPForwarding no
        X11Forwarding no
        ForceCommand internal-sftp -d %u
The %u substitutes the account's username in the path. See "man sshd_config" for the details.

Last edited by Turbocapitalist; 01-03-2020 at 03:40 AM.
 
Old 01-03-2020, 03:09 AM   #3
Simpo20
LQ Newbie
 
Registered: Jan 2020
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi Turbo,

Thanks for the reply, initially there would be approx 20-25 individual users with thier own 'home/root' directory.

Ill give that a go today - sounds so simple when someone puts it down on paper like that.

Kind Regards
 
Old 01-03-2020, 03:12 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,294
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
It's pretty easy, once you see how it fits together.

Note that I just tweaked the ChrooDirectory in the example to match the example better.
 
  


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
SFTP throwing "End of file" when doing SFTP transfer in perl exceed1 Programming 5 03-06-2010 01:34 PM
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
cannot login into SFTP server using Net::SFTP cccc Programming 1 10-31-2007 06:23 AM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 09:14 PM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 10:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:34 AM.

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