您的位置:首页 > 编程语言 > Go语言

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

2015-06-27 10:50 676 查看
我的博客已迁移到xdoujiang.com请去那边和我交流
一、基础环境
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  debian google authen