有没有办法更改默认的登录/密码提示?

有没有办法更改默认的登录/密码提示?

刚刚注意到我的两台 Linux 服务器发生了一些奇怪的事情。我们有二十几台 Ubuntu 18.04 LTS 服务器,它们都以相同的方式向我们询问提示:

# ssh admin@pl3poland
admin@pl3poland's password:

但是,我们最近开始在两台服务器上强制执行更严格的密码要求。我们更改了 /etc/pam.d/common-password 中 libpwquality 的设置。

前:

password        requisite                       pam_pwquality.so retry=3 

后:

password        requisite                       pam_pwquality.so retry=3 minlen=12 difok=3 minclass=4 maxrepeat=2 dictcheck=1 usercheck=1

看来在更改这些值之后,密码提示现在显示不同了。这是现在显示的内容:

# spawn ssh admin@spain
Password:

这是一个相对较小的差异,但它影响了我们使用 expect 脚本连接系统的一些自动化例程。我已将脚本更改为查找“sword:”而不是完整的“password:”,但我只是好奇为什么会这样,以及是否有任何方法可以将其改回来?

通过查看文档,我发现了一个名为“password-prompt”的命令,但它看起来不像是我可以用来永久设置密码前缀的东西。

有人能给我提供一个 .conf 文件或一些文档来解释如何更改这一点吗?我来自 AIX 背景,有一个名为 /etc/security/login.cfg 的文件,我们可以更改它来调整每次登录的“预告”。但我在 Ubuntu 中没有看到类似的东西。

谢谢

史蒂夫·N。

答案1

  • user@server's password用于密码验证
  • Password:用于键盘交互身份验证

两者都设置了 SSH 选项:

  • PreferredAuthentications=password
  • PreferredAuthentications=keyboard-interactiv

定义在rfc4252rfc4256 文档因此,它不太可能与 的变化有关/etc/pam.d/common-password,而更多地与 的变化.ssh/config和设置有关PreferredAuthentications,或者通过使用 选项进行设置ssh -o

答案2

看起来问题正是 Rinzwind 指出的那样。使用 ssh -vv 调试器标志,我能够看到 Ubuntu 服务器 #1(polaris)在“密码”身份验证方法处停止,而 Ubuntu 服务器 #2(spain)

为了演示,这里是调试器登录会话的尾端:

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /.ssh/id_dsa
debug1: Trying private key: /.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
admin@polaris's password:

与我的西班牙服务器上的相比:

debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /.ssh/id_dsa
debug1: Trying private key: /.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:

现在出于自己的好奇心,我真的应该花时间找出为什么一个使用密码而另一个使用键盘交互。我怀疑这是 id_rsa.pub 或 authorized_keys 条目的问题。但我还没有时间进一步研究它。

我们想出的修复预期脚本的解决方案是简单地查找“assword:”而不是之前使用的“password:”。这样,如果我们再次遇到该问题,无论我们获取的是“Password:”还是“password:”作为登录字符串的一部分,自动例程都将继续。

相关内容