์ด์ค ์ธ์ฆ์ด ๋ฐ๋์งํ๊ณ ๊ฐ์์ ์ด์ง๋ง ํ๋์จ์ด ํ ํฐ์ ๋ํ ๋์ด ์๊ณ ์ผ๋ฐ์ ์ผ๋ก ์ข์ ๋ถ์๊ธฐ๋ฅผ ์ ์งํ๋๋ก ์ ์ํ๋ค๋ฉด ์ด๋จ๊น์?
์ด ์๋ฃจ์
์ ๋งค์ฐ ๋
์ฐฝ์ ์ธ ๊ฒ์ด ์๋๋ผ ์ธํฐ๋ท์์ ์ฐพ์ ์ ์๋ ๋ค์ํ ์๋ฃจ์
์ ํผํฉํ ๊ฒ์
๋๋ค.
๊ทธ๋์ ์ฃผ์ด์ง
๋๋ฉ์ธ ์ด๋ฆ Active Directory์.
์ค๋๋ ๋ง์ ์ฌ๋๋ค์ฒ๋ผ VPN์ ํตํด ์์ ํ๋ ๋๋ฉ์ธ ์ฌ์ฉ์.
VPN ๊ฒ์ดํธ์จ์ด ์ญํ ์ ํฉ๋๋ค. ์์.
VPN ํด๋ผ์ด์ธํธ์ ๋น๋ฐ๋ฒํธ ์ ์ฅ์ ๋ณด์ ์ ์ฑ ์ ์ํด ๊ธ์ง๋์ด ์์ต๋๋ค.
์ ์น ํฌํฐ๋ท ์์ ์ ํ ํฐ๊ณผ ๊ด๋ จํ์ฌ zhlob ๋ฏธ๋ง์ด๋ผ๊ณ ๋ถ๋ฅผ ์๋ ์์ต๋๋ค. ์ต๋ 10๊ฐ์ ๋ฌด๋ฃ ํ ํฐ์ด ์๊ณ ๋๋จธ์ง๋ ๋งค์ฐ ์ฝ์ ๊ฐ๊ฒฉ์ด ์๋๋๋ค. ๋๋ ์คํ ์์ค๋ฅผ ์ํ๊ธฐ ๋๋ฌธ์ RSASecureID, Duo ๋ฑ์ ๊ณ ๋ คํ์ง ์์์ต๋๋ค.
์ ์ ์กฐ๊ฑด: ์ฃผ์ธ *์๋์ผ ์ค๋ฆฝ ํ์ฌ FreeRADIUS, SSD - ๋๋ฉ์ธ์ ์ ๋ ฅํ๋ฉด ๋๋ฉ์ธ ์ฌ์ฉ์๊ฐ ์ฝ๊ฒ ์ธ์ฆํ ์ ์์ต๋๋ค.
์ถ๊ฐ ํจํค์ง: ์๋ฆฌ๋ ์์, ๋ฌดํ๊ณผ, ์์ ๋ฐ๊ฒฝ LDAP, ํฐํธ ๋ฐ๋๊ตฐ.tlf ์ ์ฅ์์์
๋ด ์์์-CentOS 7.8.
์์ ๋ ผ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. VPN์ ์ฐ๊ฒฐํ ๋ ์ฌ์ฉ์๋ ์ํธ ๋์ ๋๋ฉ์ธ ๋ก๊ทธ์ธ๊ณผ OTP๋ฅผ ์ ๋ ฅํด์ผ ํฉ๋๋ค.
์๋น์ค ์ค์
ะ /etc/raddb/radiusd.conf ๋์ ์์ํ๋ ์ฌ์ฉ์ ๋ฐ ๊ทธ๋ฃน๋ง ํ์ฌ FreeRADIUS, ์๋น์ค ์ดํ ๋ฐ์ง๋ฆ ๋ชจ๋ ํ์ ๋๋ ํ ๋ฆฌ์ ํ์ผ์ ์ฝ์ ์ ์์ด์ผ ํฉ๋๋ค. /์ง/.
user = root
group = root
์ค์ ์์ ๊ทธ๋ฃน์ ์ฌ์ฉํ๋ ค๋ฉด ์์, ์ ์กํด์ผ ํจ ๊ณต๊ธ์ ์ฒด๋ณ ์์ฑ. ์ด๋ ๊ฒ ํ๋ ค๋ฉด ๋๋ ํ ๋ฆฌ์์ raddb/policy.d ๋ค์ ๋ด์ฉ์ผ๋ก ํ์ผ์ ๋ง๋ญ๋๋ค.
group_authorization {
if (&LDAP-Group[*] == "CN=vpn_admins,OU=vpn-groups,DC=domain,DC=local") {
update reply {
&Fortinet-Group-Name = "vpn_admins" }
update control {
&Auth-Type := PAM
&Reply-Message := "Welcome Admin"
}
}
else {
update reply {
&Reply-Message := "Not authorized for vpn"
}
reject
}
}
์ค์น ํ ์์ ๋ฐ๊ฒฝ LDAP ๋๋ ํ ๋ฆฌ์์ raddb/mods-์ฌ์ฉ ๊ฐ๋ฅ ํ์ผ์ด ์์ฑ๋จ LDAP.
๋๋ ํฐ๋ฆฌ์ ๋ํ ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ๋ง๋ค์ด์ผ ํฉ๋๋ค. raddb/mods-ํ์ฑํ.
ln -s /etc/raddb/mods-available/ldap /etc/raddb/mods-enabled/ldap
๋ด์ฉ์ ๋ค์ ํ์์ผ๋ก ๊ฐ์ ธ์ต๋๋ค.
ldap {
server = 'domain.local'
identity = 'CN=freerad_user,OU=users,DC=domain,DC=local'
password = "SupeSecretP@ssword"
base_dn = 'dc=domain,dc=local'
sasl {
}
user {
base_dn = "${..base_dn}"
filter = "(sAMAccountname=%{%{Stripped-User-Name}:-%{User-Name}})"
sasl {
}
scope = 'sub'
}
group {
base_dn = "${..base_dn}"
filter = '(objectClass=Group)'
scope = 'sub'
name_attribute = cn
membership_filter = "(|(member=%{control:Ldap-UserDn})(memberUid=%{%{Stripped-User-Name}:-%{User-Name}}))"
membership_attribute = 'memberOf'
}
}
ํ์ผ์์ raddb/์ฌ์ดํธ ํ์ฑํ/๊ธฐ๋ณธ๊ฐ ะธ raddb/์ฌ์ดํธ ํ์ฑํ/๋ด๋ถ ํฐ๋ ์น์
์์ ๊ถํ์ ๋ถ์ฌํ๋ค ์ฌ์ฉํ ์ ์ฑ
์ด๋ฆ์ธ group_authorization์ ์ถ๊ฐํฉ๋๋ค. ์ค์ํ ์ - ์ ์ฑ
์ ์ด๋ฆ์ ๋๋ ํ ๋ฆฌ์ ํ์ผ ์ด๋ฆ์ผ๋ก ๊ฒฐ์ ๋์ง ์์ต๋๋ค. ์ ์ฑ
.d, ๊ทธ๋ฌ๋ ์ค๊ดํธ ์์ ํ์ผ ๋ด๋ถ ์ง์๋ฌธ์ ์ํด.
์น์
์์ ์ธ์ฆ ๋์ผํ ํ์ผ์์ ์ค์ ์ฃผ์์ ์ ๊ฑฐํด์ผ ํฉ๋๋ค. PAM.
ํ์ผ์์ ํด๋ผ์ด์ธํธ.conf ์ฐ๊ฒฐํ ๋งค๊ฐ ๋ณ์๋ฅผ ์ง์ ํ์ญ์์ค. ์์:
client fortigate {
ipaddr = 192.168.1.200
secret = testing123
require_message_authenticator = no
nas_type = other
}
๋ชจ๋ ๊ตฌ์ฑ pam.d/radiusd:
#%PAM-1.0
auth sufficient pam_google_authenticator.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
session include password-auth
๊ธฐ๋ณธ ๋ฒ๋ค ๊ตฌํ ์ต์ ํ์ฌ FreeRADIUS ั Google ์ธ์ฆ ์ ์ฌ์ฉ์๊ฐ ๋ค์ ํ์์ผ๋ก ์๊ฒฉ ์ฆ๋ช ์ ์ ๋ ฅํ๋๋ก ์๊ตฌํฉ๋๋ค. ์ฌ์ฉ์ ์ด๋ฆ/๋น๋ฐ๋ฒํธ+OTP.
๊ธฐ๋ณธ ๋ฌถ์ ์ฌ์ฉ ์ ๋จธ๋ฆฌ์ ๋จ์ด์ง ์ ์ฃผ์ ์๋ฅผ ์์ํ์ฌ ํ์ฌ FreeRADIUS ั ๊ตฌ๊ธ ์ธ์ฆ ์, ๋ชจ๋ ๊ตฌ์ฑ์ ์ฌ์ฉํ๊ธฐ๋ก ๊ฒฐ์ ํ์ต๋๋ค. PAM ํ ํฐ๋ง ํ์ธํ ์ ์๋๋ก ๊ตฌ๊ธ ์ธ์ฆ ์.
์ฌ์ฉ์๊ฐ ์ฐ๊ฒฐํ๋ฉด ๋ค์์ด ๋ฐ์ํฉ๋๋ค.
- Freeradius๋ ์ฌ์ฉ์๊ฐ ๋๋ฉ์ธ๊ณผ ํน์ ๊ทธ๋ฃน์ ์๋์ง ํ์ธํ๊ณ ์ฑ๊ณตํ๋ฉด OTP ํ ํฐ์ ํ์ธํฉ๋๋ค.
โ์ด๋ป๊ฒ 300๋ช ์ด์์ OTP๋ฅผ ๋ฑ๋กํ ์ ์์๊น?โ
์ฌ์ฉ์๋ ๋ค์์ ์ฌ์ฉํ์ฌ ์๋ฒ์ ๋ก๊ทธ์ธํด์ผ ํฉ๋๋ค. ํ์ฌ FreeRADIUS ๊ทํ์ ๊ณ์ ์์ ์์ฉ ํ๋ก๊ทธ๋จ์ ์คํํ์ญ์์ค. ๊ตฌ๊ธ ์ธ์ฆ ์, ์ฌ์ฉ์๋ฅผ ์ํ ์ ํ๋ฆฌ์ผ์ด์ ์ QR ์ฝ๋๋ฅผ ์์ฑํฉ๋๋ค. ๋์์ด ๋ค์ด์ค๋ ๊ณณ์ ๋๋ค. ์๋ฆฌ๋ ์์ ์ ํจ๊ป .bash_profile.
[root@freeradius ~]# yum install -y shellinabox
๋ฐ๋ชฌ ๊ตฌ์ฑ ํ์ผ์ ๋ค์ ์์น์ ์์ต๋๋ค. /etc/sysconfig/shellinabox.
๊ฑฐ๊ธฐ์ ํฌํธ 443์ ์ง์ ํ๊ณ ์ธ์ฆ์๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค.
[root@freeradius ~]#systemctl enable --now shellinaboxd
์ฌ์ฉ์๋ ๋งํฌ๋ฅผ ๋ฐ๋ผ ๋๋ฉ์ธ ํฌ๋ ๋ง์ ์ ๋ ฅํ๊ณ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ํ QR ์ฝ๋๋ฅผ ๋ฐ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
์๊ณ ๋ฆฌ์ฆ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
- ์ฌ์ฉ์๋ ๋ธ๋ผ์ฐ์ ๋ฅผ ํตํด ์์คํ ์ ๋ก๊ทธ์ธํฉ๋๋ค.
- ๋๋ฉ์ธ ์ฌ์ฉ์์ ์ ํ ์ฌ๋ถ์ ๋๋ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ ์๋ฌด ์กฐ์น๋ ์ทจํ์ง ์์ต๋๋ค.
- ์ฌ์ฉ์๊ฐ ๋๋ฉ์ธ ์ฌ์ฉ์์ธ ๊ฒฝ์ฐ ๊ด๋ฆฌ์ ๊ทธ๋ฃน์ ๊ตฌ์ฑ์์ด ํ์ธ๋ฉ๋๋ค.
- ๊ด๋ฆฌ์๊ฐ ์๋ ๊ฒฝ์ฐ Google Authenticator๊ฐ ๊ตฌ์ฑ๋์ด ์๋์ง ํ์ธํฉ๋๋ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ QR ์ฝ๋์ ์ฌ์ฉ์ ๋ก๊ทธ์์์ด ์์ฑ๋ฉ๋๋ค.
- ๊ด๋ฆฌ์๊ฐ ์๋๊ณ Google Authenticator๊ฐ ๊ตฌ์ฑ๋์ด ์์ผ๋ฉด ๋ก๊ทธ์์ํ์ญ์์ค.
- ๊ด๋ฆฌ์์ธ ๊ฒฝ์ฐ Google Authenticator๋ฅผ ๋ค์ ํ์ธํ์ญ์์ค. ๊ตฌ์ฑ๋์ง ์์ ๊ฒฝ์ฐ QR ์ฝ๋๊ฐ ์์ฑ๋ฉ๋๋ค.
๋ชจ๋ ๋ ผ๋ฆฌ๋ ๋ค์์ ์ฌ์ฉํ์ฌ ์ํ๋ฉ๋๋ค. /etc/skel/.bash_profile.
๊ณ ์์ด /etc/skel/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
# Make several commands available from user shell
if [[ -z $(id $USER | grep "admins") || -z $(cat /etc/passwd | grep $USER) ]]
then
[[ ! -d $HOME/bin ]] && mkdir $HOME/bin
[[ ! -f $HOME/bin/id ]] && ln -s /usr/bin/id $HOME/bin/id
[[ ! -f $HOME/bin/google-auth ]] && ln -s /usr/bin/google-authenticator $HOME/bin/google-auth
[[ ! -f $HOME/bin/grep ]] && ln -s /usr/bin/grep $HOME/bin/grep
[[ ! -f $HOME/bin/figlet ]] && ln -s /usr/bin/figlet $HOME/bin/figlet
[[ ! -f $HOME/bin/rebel.tlf ]] && ln -s /usr/share/figlet/rebel.tlf $HOME/bin/rebel.tlf
[[ ! -f $HOME/bin/sleep ]] && ln -s /usr/bin/sleep $HOME/bin/sleep
# Set PATH env to <home user directory>/bin
PATH=$HOME/bin
export PATH
else
PATH=PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
fi
if [[ -n $(id $USER | grep "domain users") ]]
then
if [[ ! -e $HOME/.google_authenticator ]]
then
if [[ -n $(id $USER | grep "admins") ]]
then
figlet -t -f $HOME/bin/rebel.tlf "Welcome to Company GAuth setup portal"
sleep 1.5
echo "Please, run any of these software on your device, where you would like to setup OTP:
Google Autheticator:
AppStore - https://apps.apple.com/us/app/google-authenticator/id388497605
Play Market - https://play.google.com/stor/apps/details?id=com.google.android.apps.authenticator2&hl=en
FreeOTP:
AppStore - https://apps.apple.com/us/app/freeotp-authenticator/id872559395
Play Market - https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp&hl=en
And prepare to scan QR code.
"
sleep 5
google-auth -f -t -w 3 -r 3 -R 30 -d -e 1
echo "Congratulations, now you can use an OTP token from application as a password connecting to VPN."
else
figlet -t -f $HOME/bin/rebel.tlf "Welcome to Company GAuth setup portal"
sleep 1.5
echo "Please, run any of these software on your device, where you would like to setup OTP:
Google Autheticator:
AppStore - https://apps.apple.com/us/app/google-authenticator/id388497605
Play Market - https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en
FreeOTP:
AppStore - https://apps.apple.com/us/app/freeotp-authenticator/id872559395
Play Market - https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp&hl=en
And prepare to scan QR code.
"
sleep 5
google-auth -f -t -w 3 -r 3 -R 30 -d -e 1
echo "Congratulations, now you can use an OTP token from application as a password to VPN."
logout
fi
else
echo "You have already setup a Google Authenticator"
if [[ -z $(id $USER | grep "admins") ]]
then
logout
fi
fi
else
echo "You don't need to set up a Google Authenticator"
fi
ํฌํฐ๊ฒ์ดํธ ์ค์ :
- ์ฐฝ์กฐํ๋ค ๋ฐ์ง๋ฆ-์ฌ๊ธฐ๋ ์ฌ๋
- ํ์ํ ๊ทธ๋ฃน์ ์์ฑํ๊ณ ํ์ํ ๊ฒฝ์ฐ ๊ทธ๋ฃน๋ณ๋ก ์ก์ธ์ค ์ ์ดํฉ๋๋ค. ๊ทธ๋ฃน ์ด๋ฆ ์ฌ์ฉ ์์ ์ ๋ฌ๋ ๊ทธ๋ฃน๊ณผ ์ผ์นํด์ผ ํฉ๋๋ค. ๊ณต๊ธ์ ์ฒด๋ณ ์์ฑ Fortinet-๊ทธ๋ฃน-์ด๋ฆ.
- ํ์ํ ํธ์ง SSL- ํฌํธ.
- ์ ์ฑ ์ ๊ทธ๋ฃน ์ถ๊ฐ.
์ด ์๋ฃจ์ ์ ์ฅ์ :
- ์์ OTP ์ธ์ฆ์ด ๊ฐ๋ฅํฉ๋๋ค. ์์ ์คํ ์์ค ์๋ฃจ์ .
- ์ฌ์ฉ์๋ VPN์ ํตํด ์ฐ๊ฒฐํ ๋ ๋๋ฉ์ธ ์ํธ๋ฅผ ์ ๋ ฅํ์ง ์์ผ๋ฏ๋ก ์ฐ๊ฒฐ ํ๋ก์ธ์ค๊ฐ ๋ค์ ๊ฐ์ํ๋ฉ๋๋ค. 6์๋ฆฌ ๋น๋ฐ๋ฒํธ๋ ๋ณด์์ ์ฑ ์์ ์ ๊ณตํ๋ ๋น๋ฐ๋ฒํธ๋ณด๋ค ์ ๋ ฅํ๊ธฐ ์ฝ์ต๋๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก "VPN์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค"๋ผ๋ ์ ๋ชฉ์ ํฐ์ผ ์๊ฐ ์ค์ด๋ญ๋๋ค.
์ถ์ : ์ด ์๋ฃจ์ ์ Challenge-Response๊ฐ ํฌํจ๋ ๋ณธ๊ฒฉ์ ์ธ ์ด์ค ์ธ์ฆ์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ ๊ณํ์ ๋๋ค.
์ ๋ฐ์ดํธ :
์ฝ์๋๋ก ์ฑ๋ฆฐ์ง-์๋ต ์ต์
์ผ๋ก ์กฐ์ ํ์ต๋๋ค.
๊ทธ๋์ :
ํ์ผ์์ /etc/raddb/sites-enabled/default ์น์
๊ถํ์ ๋ถ์ฌํ๋ค ๋ค์๊ณผ ๊ฐ์ต๋๋ค :
authorize {
filter_username
preprocess
auth_log
chap
mschap
suffix
eap {
ok = return
}
files
-sql
#-ldap
expiration
logintime
if (!State) {
if (&User-Password) {
# If !State and User-Password (PAP), then force LDAP:
update control {
Ldap-UserDN := "%{User-Name}"
Auth-Type := LDAP
}
}
else {
reject
}
}
else {
# If State, then proxy request:
group_authorization
}
pap
}
์น์ ์ธ์ฆ ์ด์ ๋ค์๊ณผ ๊ฐ์ด ๋ณด์ ๋๋ค.
authenticate {
Auth-Type PAP {
pap
}
Auth-Type CHAP {
chap
}
Auth-Type MS-CHAP {
mschap
}
mschap
digest
# Attempt authentication with a direct LDAP bind:
Auth-Type LDAP {
ldap
if (ok) {
update reply {
# Create a random State attribute:
State := "%{randstr:aaaaaaaaaaaaaaaa}"
Reply-Message := "Please enter OTP"
}
# Return Access-Challenge:
challenge
}
}
pam
eap
}
์ด์ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋ผ ์ฌ์ฉ์ ํ์ธ์ด ์ด๋ฃจ์ด์ง๋๋ค.
- ์ฌ์ฉ์๋ VPN ํด๋ผ์ด์ธํธ์ ๋๋ฉ์ธ ํฌ๋ ๋ง์ ์ ๋ ฅํฉ๋๋ค.
- Freeradius๋ ๊ณ์ ๊ณผ ์ํธ์ ์ ํจ์ฑ์ ํ์ธํฉ๋๋ค.
- ์ํธ๊ฐ ์ ํํ๋ฉด ํ ํฐ ์์ฒญ์ด ์ ์ก๋ฉ๋๋ค.
- ํ ํฐ์ ํ์ธ ์ค์ ๋๋ค.
- ์ด์ต).
์ถ์ฒ : habr.com