码迷,mamicode.com
首页 > 其他好文 > 详细

在debian上安装google-authenticator(ssh双重认证)

时间:2015-06-27 20:05:38      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:debian google authenticator ssh

一、基础环境
1、版本
uname -v
Debian 3.2.54-2

2、相关ip
10.131.172.202

二、安装google-authenticator
1、下载google-authenticator
wget https://github.com/google/google-authenticator/archive/master.zip

2、解压
unzip master.zip

3、编译
cd /root/google-authenticator-master/libpam
./bootstrap.sh 
./configure 
make
make install

4、编译时出错提示及需要的包
1)./bootstrap.sh: 2: exec: autoreconf: not found
先查找下包
apt-cache search autoconf
autoconf - automatic configure script builder
需要安装autoconf
apt-get -y install autoconf

2)configure: error: Unable to find the PAM library or the PAM header files
先查找下包
apt-cache search libpam |grep dev
libpam0g-dev - Development files for PAM
需要安装libpam0g-dev
apt-get -y install libpam0g-dev

3)还需要libtool工具
apt-get -y install libtool

技术分享

5、根据图上看到的相关的so文件在以下地方
ll /usr/local/lib/security
-rwxr-xr-x 1 root staff   1038 Jun 26 22:33 pam_google_authenticator.la
-rwxr-xr-x 1 root staff 125089 Jun 26 22:33 pam_google_authenticator.so

6、弄个软链接
ln -s /usr/local/lib/security/pam* /lib/x86_64-linux-gnu/security

三、pam及ssh
1、在/etc/pam.d/sshd配置里修改
tac /etc/pam.d/sshd |head -1
auth       required     pam_google_authenticator.so

2、先备份下并修改相应内容
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
修改ChallengeResponseAuthentication yes
diff /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
48c48
< ChallengeResponseAuthentication yes
---
> ChallengeResponseAuthentication no

3、参数说明
ChallengeResponseAuthentication(是否允许质疑-应答(challenge-response)认证)

4、重启ssh服务
/etc/init.d/ssh restart
[ ok ] Restarting OpenBSD Secure Shell server: sshd.

四、使用命令生成密钥
google-authenticator(生成密钥的时候回提示一些问题 我这里全部回答yes)

技术分享

五、安卓手机上已经下载好了google身份验证器了(可以在QQ手机管家里找到身份验证器下载)
输入提供的密钥上输入刚才上面图片里的HFMMSP37F2YVFG5G(在.google_authenticator这个文件也有)
之后就可以看到6位数的密码

六、使用ssh连接
1、xshell客户端ssh链接

技术分享

技术分享

技术分享

技术分享

技术分享

2、linux客户端ssh链接

技术分享

七、参考文章
http://m114.org/google-authenticator-strengthen-ssh-login-security/
linux.cn/article-3725-1.html

本文出自 “7928217” 博客,请务必保留此出处http://7938217.blog.51cto.com/7928217/1666233

在debian上安装google-authenticator(ssh双重认证)

标签:debian google authenticator ssh

原文地址:http://7938217.blog.51cto.com/7928217/1666233

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!