linux-ssh + google authenticator双因子认证

一. 简述: 

随着业务的发展, 人员的增多,一套合理的权限管理方案是必不可少的,通常情况下,为了安全,便于管理,我们都会配置一组跳板机作为登录入口。这里简单聊聊登录跳板机的方式。 

  在业界,不同的公司,可能使用不同的跳板机认证方式,通常有以下几种: ssh(key/pass)、kerberos、ldap、自己开发pam模块等。。

也有一些公司通过几种认证方式进行组合式进行认证(如kerberos+ldap+google auth等)。

根据实际环境,我们采用了ssh-key + google auth组合的方案。

二. 部署:

安装相关工具包:

#yum install -y git automake libtool pam-devel
#yum -y install wget gcc make pam-devel libpng-devel



安装chrony 实际同步工具:

#yum install -y chrony
#vim /etc/chrony.conf 
 
#/etc/init.d/chrony start
#chkconfig --add chrony
#chkconfig --level 3 5 chrony
#chkconfig chrony on


安装二维码生成工具(非必须):
#wget -c http://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.gz
#tar fxvz qrencode-3.4.4.tar.gz 
#cd qrencode-3.4.4
# ./configure 
#make && make install


安装google认证工具:
#git clone https://github.com/google/google-authenticator-libpam.git
#cd google-authenticator-libpam/
#./bootstrap.sh 
#./configure 
#make && make install
#ln -sv  /usr/local/lib/security/pam_google_authenticator.so /lib64/security/pam_google_authenticator.so

三. 配置:

1. 修改sshd_config, 令其支持google auth

vim /etc/ssh/sshd_config

Port 22
SyslogFacility AUTHPRIV
LogLevel INFO
AuthenticationMethods keyboard-interactive,publickey
PermitRootLogin yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
ChallengeResponseAuthentication yes
UsePAM yes
X11Forwarding yes
PrintLastLog yes
PasswordAuthentication no

2. vim /etc/pam.d/sshd 

# cat /etc/pam.d/sshd 
auth       required     pam_google_authenticator.so
auth	   required	pam_sepermit.so
#auth       substack     password-auth
auth       include      postlogin

/etc/init.d/sshd restart

3. 生成google auth 的key

# google-authenticator 

4. 安装谷歌身份验证器,通过google auth 的key生成 实时的6位数验证码。

也可以安装google浏览器插件的方式; 

---------------------------------------------------------------------------------------------------------------------

                         深耕运维行业多年,擅长运维体系建设,方案落地。欢迎交流!

                                                    V: ywjw996

                                                    《 运维经纬 》

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值