AIX系统管理--关于unsuccessful login attempts和account_locked

关于unsuccessful login attemptsaccount_locked
系统安全加固中,我们经常要在WINUNIX中经常要失败登录尝试次数,当达到指定的次数后,系统禁止该用户登录;如果是WIN平台,由于失败登录而被锁定的账户过一段时间后会自动解锁(由相关参数设定);而AIX平台似乎没有自动解锁这一特性(或许有,只是我不了解?)。
而暂时不再使用的用户,管理员往往会人工把它锁定。
AIX中,要实现以上管理,分别修改unsuccessful login attemptsaccount_locked

值得注意的是,由于失败登录而导致的账户被锁定和手工锁定账户的结果及解决办法是不一样的。

一、unsuccessful login attempts
1.设定unsuccessful login attempts
方法一
Smitty usersuser1属性
Number of FAILED LOGINS before user account is locked设定为3
image001.png



方法二
也可以用命令行来实现
#chuser loginretries=3 user1
检查该用户属性
#lsuser -f user1
user1:

id=207


pgrp=staff


groups=staff


home=/home/user1


shell=/usr/bin/ksh


login=true


su=true


rlogin=true


daemon=true


admin=false


sugroups=ALL



admgroups=


tpath=nosak


ttys=ALL


expires=0


auth1=SYSTEM


auth2=NONE


umask=22


registry=files


SYSTEM=compat


logintimes=


loginretries=3


pwdwarntime=0


account_locked=false


minage=0


maxage=0


maxexpired=-1


minalpha=0


minother=0


mindiff=0


maxrepeats=8


minlen=8


histexpire=0


histsize=0


pwdchecks=


dictionlist=


fsize=-1


cpu=-1


data=262144


stack=65536


core=2097151


rss=65536


nofiles=2000


time_last_login=1262968379


time_last_unsuccessful_login=1262968719


tty_last_login=/dev/pts/4


tty_last_unsuccessful_login=/dev/pts/4


host_last_login=192.168.1.2


host_last_unsuccessful_login=192.168.1.2

        unsuccessful_login_count=0

roles=

2.尝试使用错误密码登录
尝试用错误密码登录3次后提示失败登录尝试达到限定的阈值,禁止登录
AIX Version 5
(C) Copyrights by IBM and by others 1982, 2005.
login: user1
user1's Password: 
3004-007 You entered an invalid login name or password.
login: user1
user1's Password: 
3004-007 You entered an invalid login name or password.
login: user1
user1's Password: 
3004-007 You entered an invalid login name or password.

AIX Version 5
(C) Copyrights by IBM and by others 1982, 2005.
login: user1
user1's Password: 
3004-303 There have been too many unsuccessful login attempts; please see

the system administrator.


login:

3.检查失败登录次数
 

 

检查失败登录次数可以用lsuser查看

 

unsuccessful_login_count已经达到4次;而account_locked属性依然没有改变,仍然为false
-bash-3.00# lsuser -f user1
user1:

id=207


pgrp=staff


groups=staff


home=/home/user1


shell=/usr/bin/ksh


login=true



su=true


rlogin=true


daemon=true


admin=false


sugroups=ALL


admgroups=


tpath=nosak


ttys=ALL


expires=0


auth1=SYSTEM


auth2=NONE


umask=22


registry=files



SYSTEM=compat


logintimes=


loginretries=3


pwdwarntime=0


account_locked=false


minage=0


maxage=0


maxexpired=-1


minalpha=0


minother=0


mindiff=0


maxrepeats=8


minlen=8


histexpire=0


histsize=0


pwdchecks=


dictionlist=


fsize=-1


cpu=-1


data=262144


stack=65536


core=2097151


rss=65536


nofiles=2000


time_last_login=1262968379



time_last_unsuccessful_login=1262969926


tty_last_login=/dev/pts/4


tty_last_unsuccessful_login=/dev/pts/5


host_last_login=192.168.1.2


host_last_unsuccessful_login=192.168.1.2


unsuccessful_login_count=4


roles=

 

 

 

 

 

或者直接浏览/etc/security/lastlog

 

# cat /etc/security/lastlog
root:

time_last_login = 1262969648


tty_last_login = /dev/pts/4


host_last_login = 192.168.1.2


unsuccessful_login_count = 0


time_last_unsuccessful_login = 1264252052


tty_last_unsuccessful_login = /dev/pts/6


host_last_unsuccessful_login = 192.168.1.77

guest:

time_last_unsuccessful_login = 1226279970


tty_last_unsuccessful_login = /dev/pts/1


host_last_unsuccessful_login = 192.168.1.217


unsuccessful_login_count = 3

user1:

time_last_login = 1262968379


tty_last_login = /dev/pts/4


host_last_login = 192.168.1.2


unsuccessful_login_count = 4 


time_last_unsuccessful_login = 1262969926


tty_last_unsuccessful_login = /dev/pts/5


host_last_unsuccessful_login = 192.168.1.2

oracle:

time_last_unsuccessful_login = 1255304971


tty_last_unsuccessful_login = 192_168_1_189_0



host_last_unsuccessful_login = 192.168.1.189:0


unsuccessful_login_count = 0


time_last_login = 1255305015


tty_last_login = 192_168_1_189_0


host_last_login = 192.168.1.189:0

informix:

time_last_unsuccessful_login = 1261962628


tty_last_unsuccessful_login = /dev/pts/0


host_last_unsuccessful_login = 192.168.1.157


unsuccessful_login_count = 0


time_last_login = 1262104409


tty_last_login = /dev/pts/3


host_last_login = 192.168.1.157

user2:

time_last_unsuccessful_login = 1262968664


tty_last_unsuccessful_login = /dev/pts/4


host_last_unsuccessful_login = 192.168.1.2


unsuccessful_login_count = 1

-bash-3.00#

4.尝试通过su – 来切换到user1
成功。可见即使账户锁定,依然可以用su – 来切换到被锁定的账户

5.解锁账户
方法一
通过SMITTY USERS来解锁USER1
image007.png



选择Reset User's Failed Login Count,在username栏输入user1

方法二
通过修改etc/security/lastlogunsuccessful_login_count的值来进行行解锁
vi /etc/security/lastlog,unsuccessful_login_count=X改为0即可

登录成功
image009.png

下载 (10.9 KB)
2010-1-8 16:56


二、account_locked
1.手工锁定用户USER1

方法一
通过Smitty users来锁定user1,user name栏输入user1;is this user account_locked栏选择true
image011.png 


方法二
# chuser account_locked=true user1

2.检查锁定状态
# lsuser -f user1 |grep account_locked

account_locked=true
尝试登录
login: user1
user1's Password: 
3004-301 Your account has been locked; please see the system administrator.

3.尝试通过su – 来切换到user1
成功登录

4.解锁账户
方法一
smitty users,将is this user account_locked属性改为false

方法二
# chuser account_locked=false user1

注意:从以上登录提示信息可以看出,在使用由于失败登录被锁定和手工锁定的账户来登录时,系统提示的信息是不一样的;而且账户(非ROOT)被锁定后依然可以通过ROOT账户来SU到该用户。

但是root用户失败登录次数达到设定值后被锁定,是不能通过其他用户SU到ROOT的,需要用光盘或磁带引导到维护模式下进行解锁。

 

image013.png

 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个 Python 银行管理系统的示例代码,包括一个 `BankAccount` 类和一个 `Bank` 类: ```python class BankAccount: def __init__(self, account_number, name, balance=0.0): self.account_number = account_number self.name = name self.balance = balance def deposit(self, amount): self.balance += amount print("Deposit successful. New balance is:", self.balance) def withdraw(self, amount): if self.balance < amount: print("Withdrawal unsuccessful. Insufficient balance.") else: self.balance -= amount print("Withdrawal successful. New balance is:", self.balance) def check_balance(self): print("Your current balance is:", self.balance) class Bank: def __init__(self, name): self.name = name self.accounts = {} def add_account(self, account_number, name, balance=0.0): if account_number in self.accounts: print("Account already exists.") else: self.accounts[account_number] = BankAccount(account_number, name, balance) print("Account created successfully.") def remove_account(self, account_number): if account_number in self.accounts: del self.accounts[account_number] print("Account removed successfully.") else: print("Account not found.") def deposit(self, account_number, amount): if account_number in self.accounts: self.accounts[account_number].deposit(amount) else: print("Account not found.") def withdraw(self, account_number, amount): if account_number in self.accounts: self.accounts[account_number].withdraw(amount) else: print("Account not found.") def check_balance(self, account_number): if account_number in self.accounts: self.accounts[account_number].check_balance() else: print("Account not found.") def main(): bank = Bank("Python Bank") while True: print("1. Create account") print("2. Remove account") print("3. Deposit") print("4. Withdraw") print("5. Check balance") print("6. Quit") choice = int(input("Enter your choice: ")) if choice == 1: account_number = input("Enter account number: ") name = input("Enter name: ") balance = float(input("Enter initial balance (optional): ") or 0) bank.add_account(account_number, name, balance) elif choice == 2: account_number = input("Enter account number: ") bank.remove_account(account_number) elif choice == 3: account_number = input("Enter account number: ") amount = float(input("Enter amount to deposit: ")) bank.deposit(account_number, amount) elif choice == 4: account_number = input("Enter account number: ") amount = float(input("Enter amount to withdraw: ")) bank.withdraw(account_number, amount) elif choice == 5: account_number = input("Enter account number: ") bank.check_balance(account_number) elif choice == 6: print("Thank you for banking with us!") break else: print("Invalid choice. Please try again.") if __name__ == '__main__': main() ``` 此代码定义了一个 `Bank` 类和一个 `BankAccount` 类,用于管理银行账户。在 `main()` 函数中,用户可以执行以下操作: 1. 创建账户 2. 删除账户 3. 存款 4. 取款 5. 查询余额 6. 退出程序 用户选择要执行的操作后,程序将相应地调用 `Bank` 类中的方法。 以上是一个 Python 银行管理系统的示例代码,可以根据自己的需要进行修改和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值