Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to jail linux user

Tags:

linux

chroot

jail

Is there something similar to chroot, but for users?

We are about to grant access to our servers for a client and would like them to see only the directories we allow.

like image 235
Andrei Serdeliuc ॐ Avatar asked May 07 '09 07:05

Andrei Serdeliuc ॐ


People also ask

How do I restrict SSH users?

Limit SSH User LoginsOpen the /etc/ssh/sshd_config file. Add an AllowUsers line at the bottom of the file with a space separated by a list of usernames. For example, user tecmint and sheena both have access to remote ssh.

How do I create a jailed SFTP user?

To create a user, we will use the "useradd" command. Here we will specify that the user must be a member of the group "sftpgroup and that their default shell is set to "nologin. By specifying the "nologin" option, we can limit the users access to only a sftp connection.

What is jailed SSH?

Jailing an SSH user to their home directory allows you (the administrator) to exercise a lot of control and security over the user accounts on a Linux system. The jailed user still has access to their home directory, but can't traverse the rest of the system.


2 Answers

A Google search on "openssh jail" led me to SSHjail for openSSH. If your client uses ssh/scp to access the said servers, this might be what you are looking for.

like image 195
Tiberiu Ana Avatar answered Oct 14 '22 06:10

Tiberiu Ana


The "best answer" from 2009 is outdated. OpenSSH now comes with the ChrootDirectory option. See http://www.debian-administration.org/articles/590 which is for an already-old version of ssh.

like image 44
huyz Avatar answered Oct 14 '22 05:10

huyz