如何强制更改 Linux 密码,即使与以前类似

如何强制更改 Linux 密码,即使与以前类似

我正在尝试更改我当前的密码红帽企业 Linux 服务器版本 5.10 (Tikanga) 但它说我的新密码太相似了。有什么办法可以强制改变吗?

$ passwd
Changing password for user XY
Changing password for XY
(current) UNIX password:
New UNIX password:
BAD PASSWORD: is too similar to the old one
New UNIX password:

答案1

如果您可以以 root 身份运行该命令,则可以强制接受更改。

例子:

$ sudo passwd myusername
Changing password for user myusername.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

答案2

简短的回答:你不能。

解决方法:

  • 更改两次,例如旧密码是 Bilbo1,

    • 更改为 Frodo1(从 Bilbo1),

    • 然后更改为 Bilbo2(来自 Frodo1)。

为什么有两个变化?

  • 第一个变化,Linux 只能比较明文 Bilbo1 和 Frodo1,

  • 在第二个 Linux 上只能比较 Frodo1 和 Bilbo2(以及所有加密的密码,您无法恢复为 Bilbo1(*))。

  • 假设您可以更改两次,这可能已被您的系统管理员禁用,以防止此类工作。

不用说,不要使用如此愚蠢的密码。

(*) 第二点,我不确定 Linux 中的这一点。

答案3

在 CentOS 上,您还可以使用该-f选项强制更改密码。

$ passwd -f username
Changing password for user username.
New password: 
Retype new password:

答案4

尝试:
sudo busybox passwd XY
(XY 是您的用户名)

我曾使用root权限为普通用户设置弱密码,有警告,但最终成功了。
但最近我又尝试了一次,但失败了。
我的最终解决方案是使用 busybox 的内部 passwd 程序,这是一个不同的程序,并且它可以工作。

我的系统是gentoo,经检查,默认passwd来自sys-apps/shadow-4.8.1-r2。

duke@duke-pc ~ $ sudo passwd duke

You can now choose the new password or passphrase.

A good password should be a mix of upper and lower case letters,
digits, and other characters.  You can use a password
that consists of 8 characters.

A passphrase should be of at least 3 words, 8 to 40 characters
long, and contain enough different characters.

Alternatively, if no one else can see your terminal now, you can
pick this as your password: "sleep=Medal2brim".

Enter new password: 
Weak password: too short.
Try again.

(....)

You can now choose the new password or passphrase.

A good password should be a mix of upper and lower case letters,
digits, and other characters.  You can use a password
that consists of 8 characters.

A passphrase should be of at least 3 words, 8 to 40 characters
long, and contain enough different characters.

Alternatively, if no one else can see your terminal now, you can
pick this as your password: "Freeze+six7nazi".

Enter new password: 
Weak password: based on a dictionary word and not a passphrase.
passwd: Authentication token manipulation error
passwd: password unchanged
duke@duke-pc ~ $ 
duke@duke-pc ~ $ sudo busybox passwd duke
Changing password for duke
New password: 
Bad password: too weak
Retype password: 
passwd: password for duke changed by root
duke@duke-pc ~ $ 

相关内容