linux:lshell

This is an old revision of the document!


Restrict SSH Access for User with LShell (Limited Shell)

LShell or Limited Shell is written in python for limiting user for specific set of commands and directories. You can create user environment with limited access, you can also enable disable commands over SSH access.

  • Install on CentOS / RHEL 7:
    # yum update
    # yum install lshell
  • Install on Debian / Ubuntu:
    # apt-get update
    # apt-get install lshell

Now set the LShell as default shell for users for which you are required. For example to change the shell of user sarah.

# chsh sarah

Changing the login shell for sarah
Enter the new value, or press ENTER for the default
	Login Shell [/bin/lshell]: /usr/bin/lshell 

You may also set the lshell as default shell for user during creation of user account as following.

# adduser --shell /usr/bin/lshell raj

Now start with the configuration of lshell. Edit lshell configuration file /etc/lshell.conf. There are 4 basic sections in configuration file.

  • [global] : In this section we defines the settings which applied globally. For example logs.
  • [default] : In this section we set default values which applied all users and groups. The settings of this section can be overridden with user and group specific settings.
  • [USERNAME] : In this section we specify user specific settings. This section settings applied to user only
  • [grp:GROUPNAME] : In this section we specify group specific settings. This section settings applied to all users of group

A [default] profile is applied for all users using lshell. You can create [username] section or a group [grp:groupname] section to customize users and group specific preferences.

The priority order is User » Group » Default. User section has highest priority and Default has lowest priority.

Quelle: https://tecadmin.net/how-to-limit-user-access-with-lshell-limited-shell/#

  • linux/lshell.1510069354.txt.gz
  • Last modified: 2017/11/07 16:42
  • by michael