使用Google身份驗證進行ssh二次驗證

什麼是谷歌身份驗證器

谷歌身份驗證器,即Google Authenticator(Google身份驗證器)v2.33 谷歌推出的一款動態口令工具,解決你們的google帳戶遭到惡意***的問題。linux

特色

一、透過QR圖碼自動設定
二、支持多個帳戶
三、支援多種語言git

開始動手

一、編輯/etc/selinux/config文件,關閉selinux
SELINUX=disabledgithub

二、yum安裝相關程序
yum -y install gcc make pam-devel libpng-devel libtool wget gitweb

三、安裝Qrencode
yum install mercurialbootstrap

四、使用git clone下載google-authenticator-libpam,安裝google authenticator PAM插件
git clone https://github.com/google/google-authenticator-libpam.gitapp

五、進入google-authenticator-libpam目錄下,執行腳本
./bootstrap.sh && ./configure && make && make installssh

六、複製google 身份驗證器pam模塊到系統下
cp /usr/local/lib/security/pam_google_authenticator.so /lib64/security/ide

七、配置/etc/pam.d/sshd文件,將認證模塊添加
auth required pam_google_authenticator.so
image.png工具

八、修改SSH服務配置/etc/ssh/sshd_config文件,將註釋去掉
ChallengeResponseAuthentication yesui

九、重啓ssh服務
service sshd restart

十、切換到須要驗證的系統帳戶,運行程序
google-authenticator
image.png

十一、谷歌身份驗證器配置
使用Google身份驗證進行ssh二次驗證
使用Google身份驗證進行ssh二次驗證
使用Google身份驗證進行ssh二次驗證


十二、驗證

接着在ssh的客戶端裏設置,以下,設置"Keyboard Interactive"方式登陸

image.png

而後再次鏈接的時候,就會提示先輸入二次身份驗證碼,再輸入用戶密碼。

image.png

image.png

image.png

相關文章
相關標籤/搜索