【发布时间】:2014-06-02 19:01:56
【问题描述】:
我有一个 perl 脚本在 ssh shell 打开后进行第二层身份验证。它要求输入密码,并且在 n 次无效尝试后,脚本应该注销用户。这在 Debian 系统上运行。
现在,问题是通常使用命令exit 以交互方式关闭 ssh shell。
当从反引号或 perl 脚本中的 system() 运行时,exit 不会被识别为有效命令。那么如何在 perl 脚本中从 ssh 会话中注销用户呢?该脚本不对 ssh 会话负责。它在遥控器上运行,并从 .bashrc 启动。
这是相关的代码段:
while ($actualpass ne $password) {
++$attempts;
if ( $attempts > $maxattempts ) {
`/bin/bash /root/ascii_breach`;
`/bin/bash exit`;
}
/bin/bash exit 显然不起作用。
【问题讨论】:
-
向父级(shell PID)
perl -e 'kill HUP => getppid()'987654325@发送信号的技巧 -
@mpapec 太棒了。正是我想要的,无需编辑系统文件。做出这样的回答?