手机版
你好,游客 登录 注册
背景:
阅读新闻

通过Google身份验证器加强Linux帐户安全

[日期:2014-05-15] 来源:Linux社区  作者:junsansi [字体:大 中 小]

默认情况下,令牌只在30秒内有效,由于客户端和服务器时间不完全一致的因素,可以将时间窗口加大到最长4分钟,是否要这么做:

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) y

是否限制尝试次数,每30秒只能尝试最多3次:

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

密钥生成好之后,下面修改PAM中关于ssh的配置,编辑/etc/pam.d/sshd文件:

# vim /etc/pam.d/sshd

增加一行:

auth required pam_google_authenticator.so

接下来再修改ssh的配置文件,编辑/etc/ssh/sshd_config文件:

# vim /etc/ssh/sshd_config

将ChallengeResponseAuthentication no修改为ChallengeResponseAuthentication yes

然后重新启动ssh服务:

 

当再次使用jss用户以SSH方式登录时,就会提示输出验证码:

[root@mysqldb02 ~]# ssh jss@192.168.30.249

Verification code:

那么,验证码从哪里来呢,朋友,您这算是问到点儿上了。拿出你的手机,安装一款名叫:Google身份验证器的应用。在打开的应用界面中新增帐户,然后会出现两个选择:扫描条形码(二维码),或者选择输出提供的密钥,任选其一即可。

有同学可能会问,这两项信息从哪里来呢,同学,请你再仔细看下,执行google-authenticator命令后首先输出的信息,那个HTTP的网址,打开你就会发现,原来它是个图片二维码,扫描即可。若网址打不开也没关系,选择密钥就是了嘛。

帐户添加完成后,您应该就能在手机上看到它生成的验证码了,先输入验证码,然后再输入密码,只有验证码和密码都输入正确,才能正常登录。

Password:

Last login: Tue Jan 14 10:14:33 2014 from 192.168.30.246

注意哟,输入验证码的时间最长只有30秒钟,超时之后该验证码就失效,需要到手机端获取新的验证码才行。

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-05/101791.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款