LinuxQuestions.org
Visit Jeremy's Blog.
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 07-17-2018, 02:06 AM   #1
dushyantg
Member
 
Registered: Jun 2016
Posts: 70

Rep: Reputation: Disabled
Limited User Access


Hi,

I am using ubuntu 16.04 and I want to create a user which can only access its home directory.

I have followed the steps mentioned in below url :

https://www.tecmint.com/restrict-ssh...chrooted-jail/

https://www.digitalocean.com/communi...ific-directory

but it won't work and it makes user not able to login to the server.
kindly help..

Thanks
 
Old 07-17-2018, 04:40 AM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
I don't think anyone is going to be able to help without more information. Both links you posted are multi-step and you failed to indicate at which step it failed or for that matter, which link tutorial you used. "It won't work" is not helpful so if you want help, details.
 
Old 07-17-2018, 05:30 AM   #3
dushyantg
Member
 
Registered: Jun 2016
Posts: 70

Original Poster
Rep: Reputation: Disabled
When I added below lines

Subsystem sftp internal-sftp
Match group sftpusers
ChrootDirectory %h
ForceCommand internal-sftp

and restart the service of sshd i am not able to login to server via ssh or sftp.

it gives error of connection failed.
 
Old 07-18-2018, 11:25 AM   #4
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Hi dushyantg,

Yancek (above post) has a point - more details would still help.

By "limiting access to home", do you mean read-only elsewhere, or no permissions at all (i.e. can't even view directory contents ...) ? Explaining what you are trying to do this for would also help.

I suppose changing the permissions on the entire file system to 700 would allow only root to view, list, read or write in any directories other than /home/$user$ ... I guess using the appropriate masks in fstab would be the easiest way to do this (probably 077) ... Still - we're shooting in the dark here until you provide more context.

Cheers.
 
Old 07-18-2018, 12:18 PM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by dushyantg View Post
but it won't work and it makes user not able to login to the server.
It sounds like the permissions are incorrect. If the chroot is writable by the user, then any amount of mischief is possible. The chroot must be owned by root and only writable by root, or else the OpenSSH server will refuse to let that user log in. Same for all the directories above it.

Code:
ls -lhd /
ls -lhd /home/
ls -lhd /home/user1/
If you have the following lines appended to /etc/ssh/sshd_config

Code:
Subsystem sftp internal-sftp
Match group sftpusers
        ChrootDirectory %h
        ForceCommand internal-sftp
Then it will chroot the SFTP session to the users' home directory. So that directory has to be owned by root and not writable by anyone, not even the user. There are two ways to deal with that.

1) You can have root create files and subdirectories and have them owned by the user. That has the disadvantage that anything in the users' directories has to be created manually by root.

2) You can create a subdirectory in the chroot with the users' name and otherwise work as normal. The disadvantage is that some think it looks funny to those outside the chroot. Then you can chroot to the home directory and start the session within the subdirectory.

Code:
Match group sftpusers
        ChrootDirectory %h
        ForceCommand internal-sftp -d %u
 
Old 07-31-2018, 07:24 AM   #6
dushyantg
Member
 
Registered: Jun 2016
Posts: 70

Original Poster
Rep: Reputation: Disabled
I have created a user XYZ and its having its home directory now I want XYZ to have full access on its home directory and he/she can have 777 permission on that but rest of all files it will not have even 700, I mean that user can't access rest of the files/directories not even read permission.
 
Old 07-31-2018, 07:25 AM   #7
dushyantg
Member
 
Registered: Jun 2016
Posts: 70

Original Poster
Rep: Reputation: Disabled
I have created a user XYZ and its having its home directory now I want XYZ to have full access on its home directory and he/she can have 777 permission on that but rest of all files it will not have even 700, I mean that user can't access rest of the files/directories not even read permission.
 
Old 07-31-2018, 07:28 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Which approach are you trying #1 or #2 above?

The chroot directory must not be writable by anyone other than root. Which permissions are there currently?

Code:
ls -lhd ~someuser/

ls -lh ~someuser/
 
  


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
Limited user access with key control to sftp only? newbie14 Linux - Security 6 10-08-2013 03:43 AM
Create new user with limited folder access ITTrucker Linux - Newbie 6 03-05-2013 10:15 AM
limited access user sunlinux Linux - Newbie 3 06-15-2009 12:26 PM
create very limited linux user, only give access to rdesktop treyhphp Linux - Newbie 14 02-18-2009 02:19 PM
Limited User Access Jakeh2k1 Red Hat 1 06-07-2005 07:03 AM

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

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