2015-07-13 57 views
0

我正在嘗試爲亞馬遜EC2 Ubuntu實例創建身份驗證過程,該實例將要求使用Amazon生成的密鑰對,並使用Google-Authenticator。 Ergo我想用我的pem文件登錄到實例,然後提示驗證碼提示。如何創建一個pem文件+ google-authenticator訪問Amazon EC2?

Verification code: 

我設法使用我的pem文件登錄到我的服務器。我還設法成功安裝Google-Authenticator,並使用它來與我創建並提供特定密碼的單獨用戶(而不是ubuntu)一起登錄。

在我/etc/ssh/sshd_config我:

ChallengeResponseAuthentication yes 
PasswordAuthentication no 
UsePAM yes 
AuthenticationMethods keyboard-interactive 

和我/etc/pam.d/sshd

@include common-auth 
auth required pam_google_authenticator.so 

如果我添加publickeyAuthenticationMethods然後在登錄時提示我輸入密碼,而不是使用PEM我提供的文件:

ssh -i my-key.pem [email protected]*.*.*.* 

我如何獲得OpenSSH通過pem文件進行身份驗證 - > google-authenticator?

謝謝!

回答

1

我的解決方案是通過pem文件,密碼和驗證OTP進行檢查。爲此,我有:

在:/etc/pam.d/sshd/

@include common-auth 
auth required pam_sepermit.so 
auth required pam_google_authenticator.so 

在:/etc/ssh/sshd_config/

AuthenticationMethods publickey,keyboard-interactive 

如上述CONFIGS的其餘部分。注意publickey出現在keyboard-interactive之前AuthenticationMethods,否則驗證碼先出現然後pem文件檢查。