亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.430618.com 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

google Authenticator(谷歌身份驗證器),是谷歌公司推出的一款動態令牌工具,解決賬戶使用時遭到的一些不安全的操作進行的“二次驗證”,認證器基于RFC文檔中的HOTP/TOTP算法實現 ,是一種從共享秘鑰和時間或次數一次性令牌的算法。在實際應用中可以通過認證器方式對賬戶有更好的保護

下面在centos7下利用Google Authenticator實現SSH登錄的二次身份驗證

1、配置EPEL源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache
CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

2、安裝Google Authenticator

yum install google-authenticator -y
CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

3、google-authenticator初始化配置

哪個賬號需要動態驗證碼,切換到該賬號下操作進行操作 下面創建如下一個賬戶進行操作

useradd yuanfan
passwd yuanfan
su - yuanfan
google-authenticatorYour new secret key is: G5RR2IJG2X74MI4ADW622R6PUA #如果在手機的谷歌身份驗證器上不想通過"掃描條形碼"的方式添加,就輸入這個key,通過"手動輸入驗證碼的方式"Your verification code is 906194
Your emergency scratch codes are:  
#下面會生成5個緊急驗證碼(當無法獲取動態驗證碼或驗證碼不能使用時可以使用這5個),
#需要注意的是:這5個驗證碼用一個就會少一個!請保存好!
  45731126
  22009120
  27836115
  94685459
  48945214

Do you want me to update your "/home/yuanfan/.google_authenticator" file? (y/n) y #提示是否要更新驗證文件,選擇yDo you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y # 禁止使用相同口令
By default, a new token is generated every 30 seconds by the mobile App.
In order to compensate for possible time-skew between the client and the server,
we allow an extra token before and after the current time. This allows for a
time skew of up to 30 seconds between authentication server and client. If you
experience problems with poor time synchronization, you can increase the window
from its default size of 3 permitted codes (one previous code, the current
code, the next code) to 17 permitted codes (the 8 previous codes, the current
code, and the 8 next codes). This will permit for a time skew of up to 4 minutes
between client and server.
Do you want to do so? (y/n) y #默認動態驗證碼在30秒內有效,由于客戶端和服務器可能會存在時間差,可將時間增加到最長4分鐘,是否要這么做:這里選擇y
If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting? (y/n) y #是否限制嘗試次數,每30秒只能嘗試最多3次,這里選擇y進行限制
CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

4、修改SSH登錄相關配置文件參數

如下行添加如下參數

vim /etc/pam.d/sshd  (如下位置增加下面一行)
auth required pam_google_authenticator.so


vim /etc/ssh/sshd_config 
將ChallengeResponseAuthentication修改為yes
ChallengeResponseAuthentication yes

service sshd restart
CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

5、手機下載google身份驗證器

以Android/ target=_blank class=infotextkey>安卓手機為例 掃描QR碼方式來進行綁定

CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

6、登錄驗證測試

ssh yuanfan@localhost

然后輸入手機google身份驗證器生成的動態驗證碼(每30秒更新一次)

CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

SecureCRT登錄時,將Keyboard Interactive登錄方式調整為第一個位置

CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 


CentOS7下利用Google Authenticator實現SSH登錄的二次身份驗證

 

注意,如果沒有用root用戶進行第三步的操作,需要先其它用戶登錄后su root切換到root

https://wiki.archlinux.org/index.php/Google_Authenticator

分享到:
標簽:CentOS7
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定