易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux下锁用户与解锁问题

Linux下锁用户与解锁问题 [原创 2010-02-03 21:44:35]   
字号:大 中 小
一:登录失败次回超过限制
1)锁用户的设定
/etc/pam.d/下包含各种认证程序或服务的配置文件。编辑这些可限制认证失败次数,当失败次数超过指定值时用户会被锁住。
在此,以run level为3的时候,多次登录登录失败即锁用户为例:
在/etc/pam.d/login文件中追加如下两行:
auth required /lib/security/pam_tally.so onerr=fail no_magic_root
account required /lib/security/pam_tally.so deny=3 no_magic_root reset
deny=3 设置登录失败3次就将用户锁住,该值可任意设定。
如下为全文见设定例:
auth      required pam_securetty.so
auth      required pam_stack.so service=system-auth
auth      required pam_nologin.so
auth      required pam_tally.so onerr=fail no_magic_root
account   required pam_stack.so service=system-auth
account   required pam_tally.so deny=3 no_magic_root reset
password  required pam_stack.so service=system-auth
session   required pam_stack.so service=system-auth
session   optional pam_console.so
这样当用户在run level=3的情况下登录时,/var/log/faillog会自动生成,裏面记录用户登录失败次数等信息。
可用"faillog -u 用户名"命令来查看。
当用户登录成功时,以前的登录失败信息会重置。
2)用户的解锁
用户因多次登录失败而被锁的情况下,可用faillog命令来解锁。具体如下:
faillog -u 用户名 -r
此命令实行后,faillog里记录的失败信息即被重置,用户又可用了。
关於faillog的其他命令。。参见man failog。
二:手动锁定用户禁止使用
可以用usermod命令来锁定用户密码,使密码无效,该用户名将不能使用。
如: usermod -L 用户名
解锁命令:usermod -U 用户名


相关文档:

一个Linux下C线程池的实现

      什么时候需要创建线程池呢?简单的说,如果一个应用需要频繁的创建和销毁线程,而任务执行的时间又非常短,这样线程创建和销毁的带来的开销就不容忽视,这时也是线程池该出场的机会了。如果线程创建和销毁时间相比任务执行时间可以忽略不计,则没有必要使用线程池了。
   下面是 ......

在Linux服务器上如何开启安全的SNMP代理

在各种Linux分发版中,大多数都已经默认集成了snmpd,比如在suse10中,你可以这样开启snmpd:
  
  suse10:~ # /etc/init.d/snmpd start
  
  如果没有默认安装,你要做的就是自己来编译snmpd,按照下边的步骤,非常简单。
  
  编译和安装
  对于Linux平台,我们推荐使用Net-SNMP,它实现了标准的SNM ......

linux定时器设置

10.5.2 精通定时器设置
函数alarm设置的定时器只能精确到秒,而以下函数理论上可以精确到微妙:
#include  <sys/select.h>
#include  <sys/itimer.h>
int getitimer(int which, struct itimerval *value);
int setitimer(int which, const struct itimerval
*value, struct itimerval *ovalue ......

Linux GCC make文件的写法2

文件在两个文件夹:
inc/hello.h
main/hello.c, main.c, Makefile
文件内容:
hello.h
void hello(char name[]);

hello.c
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}

main.c
#include <stdio.h>
#include "../inc/hello.h"
// The second
int main( ......

Linux GCC make文件的写法3

 包含3个文件夹
目录组织结构如下:
inc/hello.h
main/main.c, Makefile
src/hello.c
文件内容如下:
hello.h:
void hello(char name[]);
main.c:
#include <stdio.h>
#include "../inc/hello.h"
// The second hello.h should in ""
int main()
{
hello("GCC");
printf("Haha Linux Ub ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号