0

我正在尝试为 OPEN SSH 实现两级身份验证,第一个是 ssh 公钥和私钥身份验证,第二个是 OTP 身份验证,我正在使用谷歌身份验证器。一切都按预期工作,直到第一级身份验证并生成 OTP 并将其作为第二级的输入。我被困在这里..如果 OTP 匹配,我正在执行命令给用户 shell。我不清楚如果它不匹配,我应该做什么,因为第一级身份验证已经完成。我应该如何将用户从 shell 中注销...?

下面是代码:

if(validate(secretkey,otp)):
    print("OTP Matched")
    try:
        check_call(['/bin/bash'])
    except Exception,e:
        print("Error Giving Shell to user: "+str(e))
else:
try:
    check_call(['/bin/bash'])
    check_call(['exit'])
    except Exception,e:
        print("Error Exiting the user: "+str(e))
    print("Authentication Failed")
4

0 回答 0