Skip to content

Commit

Permalink
deploy on a new server
Browse files Browse the repository at this point in the history
  • Loading branch information
weiyu10 committed Aug 19, 2016
1 parent 9ea5caa commit 3a6377f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.ldif
google-authenticator/
config
4 changes: 4 additions & 0 deletions configrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root_password="ldapiswonderful"
dc_root="com"
dc_leaf="weiyu"
dc="dc=weiyu,dc=com"
32 changes: 21 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/bin/bash
# 安装和配置openldap+sasl+google_authenticator
# 操作系统: CentOS 7.2
# Install and config openldap+sasl+google_authenticator
# OS; CentOS 7.2

# 管理员密码
root_password="ldapiswonderful"
dc_root="com"
dc_leaf="weiyu"
dc="dc=weiyu,dc=com"
export LC_ALL=C
export LANG=C
export PATH=$PATH:/usr/local/bin
setenforce 0

SOURCE ./config

# Config and install cyrus-sasl
yum -y install epel-release-7-6.noarch
yum -y install cyrus-sasl-plain cyrus-sasl-lib cyrus-sasl-devel \
cyrus-sasl oathtool gcc autoconf openldap-servers \
openldap-devel openldap-client automake pam-devel \
libtool-ltdl libtool

# Gengrate root password
root_password_ssha=`slappasswd -s "${root_password}"`
Expand All @@ -24,9 +32,6 @@ if [ ! -e /usr/local/lib/security/pam_google_authenticator.so ]; then
exit 1
fi

# Config and install cyrus-sasl
yum -y install cyrus-sasl-plain cyrus-sasl-lib cyrus-sasl-devel cyrus-sasl oathtool

echo "
SOCKETDIR=/run/saslauthd
MECH=pam
Expand All @@ -42,8 +47,13 @@ account include password-auth
systemctl start saslauthd
systemctl enable saslauthd

# debug pam
touch /etc/pam_debug
echo '*.debug /var/log/auth.log' > /etc/rsyslog.d/pam.conf
systemctl restart rsyslog

# Check sasl config
adduser test -p test
adduser test -p '$6$oX3U2JJF$HKcfCIn7A3u9y3VB3RBG2OQ437rV2hITMRBTIXxrvPc3qgPzhwggZabwtVahoCCmBGJoXyjVnR5TBfQDgP79B1'
su test -c "google-authenticator -t -d -f -r 1 -R 15 -w 3"
test_key=`cat /home/test/.google_authenticator | head -1`
code=`oathtool --totp --base32 -d6 "${test_key}"` && testsaslauthd -s ldap -u test -p "test${code}"
Expand Down

0 comments on commit 3a6377f

Please sign in to comment.