一. 简述: 

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

  在业界,不同的公司,可能使用不同的跳板机认证方式,通常有以下几种: 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

                                                    《 运维经纬 》

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐