linux中lshell搭建

本文介绍了一种方法,通过使用lshell工具来限制Linux系统中的用户只能访问指定的文件夹,并提供了详细的步骤和配置文件样例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有朋友想用我的linux服务器,准备给他开一个权限,只允许他们访问固定的文件夹。但是这个东西百度了好久都没有万全之策,后来通过问我们伟大的运维攻城狮,终于这个问题得以解决~

撒花,撒花,此时应有100个赞,给我亲爱的运维哥哥疯狂打call!!!

1、寻找lshell这个东东,一开始运维同学给我丢了一个github地址,我是一脸的懵逼与茫然,惆怅呀!我对这块真的是不好呀!废话少说,丢地址:https://github.com/ghantoos/lshell/blob/master/README.md lshell链接地址

2、在linux中,执行以下命令: 

git clone https://github.com/ghantoos/lshell.git

python setup.py install --no-compile --install-data=/usr/{pkg,local}/ 
groupadd  lshell
vim /usr/local/etc/lshell.conf 
useradd ceshi1
useradd ceshi2
passwd ceshi1
passwd ceshi2
usermod -aG lshell ceshi1
usermod -aG lshell ceshi2
chsh -s /usr/bin/lshell ceshi1
chsh -s /usr/bin/lshell ceshi2

3、编辑lshell的配置文件,命令如下:

vim /usr/local/etc/lshell.conf 

在文件里面加入以下内容

# CONFIGURATION START
[global]
logpath         : /var/log/lshell/
loglevel        : 2
[default]
allowed         : ['ls', 'echo','ll']
forbidden       : [';', '&', '|','`','>','<', '$(', '${']
warning_counter : 2
aliases         : {'ll':'ls -l'}
strict          : 0
[grp:users]
warning_counter : 5
overssh         : - ['ls']
[ceshi]
allowed         : + ['ping'] - ['ls']
path            : - ['/usr/local']
strict          : 1
home_path       : '/home/ceshi'
[ceshi1]
allowed         : + ['ping','pwd'] - ['ls']
path            : - ['/usr/local']
strict          : 1
home_path       : '/home/ceshi1'
# CONFIGURATION END


4、重启一下lshell

lshell --config /usr/local/etc/lshell.conf 

5、进行测试,你会发现测试1的用户只允许访问home/ceshi 文件夹





It fails with the following output: Change Dir: 'N:/LED_TEST/cmake-build-debug-stm32cube/CMakeFiles/CMakeScratch/TryCompile-1765by' Run Build Command(s): M:/STM32CubeCLT_1.18.0/Ninja/bin/ninja.exe -v cmTC_1e276 [1/2] M:\Stm\stm32cubeclt\STM32CubeCLT_1.18.0\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe -std=gnu11 -fdiagnostics-color=always -o CMakeFiles/cmTC_1e276.dir/testCCompiler.c.obj -c N:/LED_TEST/cmake-build-debug-stm32cube/CMakeFiles/CMakeScratch/TryCompile-1765by/testCCompiler.c [2/2] C:\Windows\system32\cmd.exe /C "cd . && M:\STM32CubeCLT_1.18.0\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe CMakeFiles/cmTC_1e276.dir/testCCompiler.c.obj -o cmTC_1e276.exe -Wl,--out-implib,libcmTC_1e276.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." FAILED: cmTC_1e276.exe C:\Windows\system32\cmd.exe /C "cd . && M:\STM32CubeCLT_1.18.0\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe CMakeFiles/cmTC_1e276.dir/testCCompiler.c.obj -o cmTC_1e276.exe -Wl,--out-implib,libcmTC_1e276.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." M:/STM32CubeCLT_1.18.0/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--major-image-version' M:/STM32CubeCLT_1.18.0/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. 什么情况
最新发布
08-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值