CentosSSH使用Google Authenticator二次验证
时间:2014-04-29 23:44 来源:linux.it.net.cn 作者:it
CentOS安装所需组件:
1
yum -y install mercurial pam-devel
安装Google Authenticator:
1
2
3
4
5
6
#http://www.haiyun.me
wget --no-check-certificate https://google-authenticator.googlecode.com/files/libpam-google-authenticator-1.0-source.tar.bz2
tar jxvf libpam-google-authenticator-1.0-source.tar.bz2
cd libpam-google-authenticator-1.0
make
make install
SSH登录时调用google-authenticator模块,编辑:
1
/etc/pam.d/sshd
第一行添加:
1
auth required pam_google_authenticator.so
修改SSH配置文件:
1
vim /etc/ssh/sshd_config
添加或修改以下内容:
1
2
ChallengeResponseAuthentication yes
UsePAM yes
重启SSH:
1
/etc/init.d/sshd restart
生成google-authenticator配置,运行:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
google-authenticator
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@node1.www.haiyun.me%3Fsecret%3DABEXG5K6CVB56BXY
#此网址为生成的二维码,客户端扫描
Your new secret key is: www.haiyun.me
Your verification code is 582849
Your emergency scratch codes are:
30776626
14200155
80795568
23936997
21919909
#上面几行数字为应急码
Do you want me to update your "/root/.google_authenticator" file (y/n) y
#更新配置文件
Do 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, tokens are good for 30 seconds and 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. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) n
#客户端与服务器时间误差
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
#次数限制
Android安装google-authenticator客户端,扫描添加上方网址的二维码,以后在登录服务器时输入账号密码的同时还需输入google-authenticator即时生成的验证码才能登录。
1
2
3
ssh www.haiyun.me
Verification code:
Password:
(责任编辑:IT)
CentOS安装所需组件:
安装Google Authenticator:
SSH登录时调用google-authenticator模块,编辑:
第一行添加:
修改SSH配置文件:
添加或修改以下内容:
重启SSH:
生成google-authenticator配置,运行:
Android安装google-authenticator客户端,扫描添加上方网址的二维码,以后在登录服务器时输入账号密码的同时还需输入google-authenticator即时生成的验证码才能登录。
(责任编辑:IT) |