주식회사 누리아이티

정보자산의 보안강화를 위한 3단계 인증 보안SW 및 지문인식 OTP/출입/보안카드 전문기업

▶ BaroSolution/가이드

보안강화를 위하여 Radius 환경에서 3단계 인증 솔루션인 BaroPAM 솔루션을 적용하는 방법

누리아이티 2019. 8. 26. 12:26

목차

1. RADIUS 인증

2. FreeRADIUS 설치 및 설정
2.1 FreeRADIUS 설치
2.2 FreeRADIUS 설정

 

3. BaroPAM 설치 및 설정
3.1 BaroPAM 설치 전 준비사항
3.2 BaroPAM 설치 모듈 다운로드
3.3 BaroPAM 환경 설정 파일 생성

3.4 BaroPAM 환경 설정

4. FreeRADIUS 연동 테스트
4.1 테스트할 계정 생성

4.2 FreeRADIUS 데몬 디버그 모드로 실행

4.3 FreeRADIUS 데몬 실행

4.4 FreeRADIUS 데몬 종료

5. About BaroPAM

 

 

1. RADIUS 인증

 

RADIUS(Remote Authentication Dial In User Service, 원격 인증 전화 사용자 서비스 위치)는 네트워킹 프로토콜로 사용자가 네트워크에 연결하고 네트워크 서비스를 받기 위한 중앙 집중화된 인증, 인가, 회계 (AAA, 회계 Accounting은 인증, 인가 후 각종 사후 처리를 맡는다.) 관리를 제공한다. RADIUS 1991년 서버 접근 인증, 회계 프로토콜로써 Livingston Enterprises, Inc. 에서 개발했다. 그리고 후에 IETF표준으로 등재되었다.

 

지원 범위가 넓고 유비쿼터스 환경에서도 사용이 가능하기에 ISP와 기업들이 인터넷이나 인트라넷 접근을 관리하거나 무선 네트워크 인증, 통합 메일 서비스 등에 자주 쓰인다. 모뎀, 무선 액세스 포인트, 디지털 가입자 회선, 가상 사설망, TCP  UDP 포트, 웹 서버 등에 사용된다.

 

RADIUS는 응용 계층에서 작동하는 클라이언트 및 서버 프로토콜이며 사용자 데이터그램 프로토콜을 통해서 전송된다. 원격 접속 서버, 가상 사설망, 네트워크 스위치의 포트 인증, 네트워크 엑세스 서버(NAS) 이들 모두는 RADIUS서버와 통신하는 컴포넌트를 가진다. RADIUS는 종종 IEEE 802.1X 인증의 기반이 되기도 한다.

 

RADIUS 서버는 유닉스 시스템이나 윈도우 서버에서 자주 백그라운드 프로세스로 실행된다.

 

RADIUS 인증 과정인 프로세스 흐름은 비교적 간단하지만 이해하는 것이 중요하다.

 

1. 어플리케이션 클라이언트는 어플리케이션 서버에 연결을 시도하고 일회용 인증키와 함께 자격 증명(로그인-ID와 비밀번호)을 제공한다.

2. 어플리케이션 서버가 이 정보를 수신하고 로컬 카탈로그에서 사용자를 찾고 인증 유형이 PAM인지 확인한다.

3. 그런 다음 외부 사용자를 인증할 위치를 결정한다.

4. RADIUS 연결 정보를 사용하여 어플리케이션 서버는 자격 증명 세부 정보를 RADIUS 서버로 전달한다.

5. RADIUS 서버는 먼저 PAM, Active Directory, LDAP 서비스 등이 될 수 있는 PAM를 사용하여 로그인-ID / 비밀번호 "기본 인증(Primary Authentication)"을 한다.

6. 유효성이 확인되면 RADIUS 서버는 2차 인증 서비스인 BaroPAM 모듈로 일회용 인증키 "2차 인증(Secondary Authentication)"을 한다.

7. 유효성이 확인 된 경우 RADIUS 서버는 "Access-Accept" 응답을 어플리케이션 서버로 다시 전달한 다음 연결을 수락하고 완료한다.

 

 

2. FreeRADIUS 설치 및 설정

2.1 FreeRADIUS 설치

 

[root@localhost ~]# yum install freeradius freeradius-utils

 

설치된 FreeRADIUS를 제거 할려고 할 때 è yum erase freeradius freeradius-utils

 

 

2.2 FreeRADIUS 설정

 

사용자와 그룹을 모두 root로 다음과 같이 변경한다

 

[root@localhost ~]# vi /etc/raddb/radiusd.conf
#user = radiusd
#group = radiusd
user = root
group = root

 

FreeRADIUS 사용은 사용자의 홈 디렉토리에 있는 BaroPAM에 액세스하려면 root로 실행해야 한다.

 

보다 쉬운 문제 해결을 위해 log 지시문에서 /etc/raddb/radiusd.conf를 편집하여 추가 로깅을 활성화 한다

 

auth = yes
auth_badpass = yes
auth_goodpass = yes

 

PAM을 활성화 하려면 /etc/freeradius/sites-enabled/default를 편집 해야 한다. PAM이 활성화 되도록 #PAM 라인의 주석을 해제한다.

 

[root@localhost ~]# vi /etc/raddb/sites-enabled/default
 
#Pluggable Authentication Modules.
pam

 

다음과 같이 PAM을 활성화 시키다.

 

[root@localhost ~]# ln -s /etc/raddb/mods-available/pam /etc/raddb/mods-enabled/pam

 

Ipv4addr secret를 다음과 같이 변경한다.

 

[root@localhost ~]# vi /etc/raddb/clients.conf
 
client localhost {
ipaddr = 127.0.0.1
ipv4addr = *    # any.  127.0.0.1 == localhost
secret = baropam
require_message_authenticator = no
nas_type = other
}

 

인증 유형을 PAM으로 다음과 같이 변경한다.

 

[root@localhost ~]# vi /etc/raddb/users
 
DEFAULT Group == "disabled", Auth-Type := Reject
Reply-Message = "Your account has been disabled."
DEFAULT Auth-Type := PAM

 

필요한 경우 Linux 방화벽에 RADIUS가 사용하는 1812 포트를 다음과 같이 허용한다.

 

[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=1812/udp
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=1813/udp
[root@localhost ~]# firewall-cmd --reload

 

자동 시작을 위한 RADIUS 서비스를 생성한다.

 

[root@localhost ~]# systemctl enable radiusd.service

 

) Sophos SSLVPN Authentication server 설정 화면

 

  

) FotiGate SSLVPN Authentication server 설정 화면

 

 

 

 

3. BaroPAM 설치 및 설정

 

BaroPAM솔루션은 정보자산의 보안 강화를 위하여 인증이 필요한 다양한 운영체제와 애플리케이션에 누구나 손쉽게 바로 적용할 수 있는 플러그인 가능한 인증 모듈(PAM, Pluggable Authentication Module) 방식을 기반으로 하는 보안에 최적화된 솔루션이다.

 

 

3.1 BaroPAM 설치 전 준비사항

 

PAM 모듈을 사용하기 위해서는 기본적으로 PAM 패키지가 반드시 설치되어 있어야 한다. 설치 확인은 다음의 명령어를 실행하여 확인한다. 만약, 설치되어 있지 않으면 Redhat, CentOS "yum install *pam*" 그외는 "sudo apt-get install pam" 명령어로 설치하면 된다.

 

[root]# rpm -qa | grep pam
pam_smb-1.1.7-7.2.1
pam_passwdqc-1.0.2-1.2.2
pam-0.99.6.2-14.el5_11
pam_krb5-2.2.14-22.el5
pam-devel-0.99.6.2-14.el5_11
pam_ccreds-3-5
pam_smb-1.1.7-7.2.1
pam_pkcs11-0.5.3-26.el5
pam-devel-0.99.6.2-14.el5_11
pam_passwdqc-1.0.2-1.2.2
pam-0.99.6.2-14.el5_11
pam_ccreds-3-5
pam_krb5-2.2.14-22.el5
pam_pkcs11-0.5.3-26.el5

 

Redhat, CentOS인 경우 "Selinux""Security Enhanced Linux"의 약자로 기본의 리눅스보다 더욱 뛰어난 보안정책을 제공하는데, 너무 뛰어난 나머지 활성화 되어 있을 경우 보안문제로 막혀서 BaroPAM이 안되는 부분이 발생(Failed to open tmp secret file  "/usr/baropam/.baro_auth~" [Permission denied])한다. 그래서 왠만하면 대부분이 비활성화(SELINUX=enforcing disabled)한다.

 

[root] /etc > vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
 
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0

 

바로 적용은 되지 않으며 재부팅을 해야 적용이 된다.

 

재부팅을 하지 않고 현재 접속된 터미널에 한해 변경된 내용을 적용하고 싶을 경우 다음의 명령어를 실행하면 된다.

 

[root] /etc > /usr/sbin/setenforce 0

 

BaroPAM 인증 모듈을 다운로드 및 설치하기 위해서 root 계정으로 접속한 후 모듈을 다운로드 및 설치하기 위한 디렉토리(/usr/baropam)를 다음과 같이 생성한다.

 

[root]# mkdir /usr/baropam

 

BaroPAM 모듈을 다운로드 및 설치하기 위한 디렉토리의 권한(읽기, 쓰기, 실행)을 다음과 같이 부여한다.

 

[root]# chmod -R 777 /usr/baropam

 

 

3.2 BaroPAM 설치 모듈 다운로드

 

BaroPAM 인증 모듈은 root 계정으로 접속한 후 모듈을 다운로드 및 설치하기 위한 디렉토리(/usr/baropam)로 이동하여 모듈을 다운로드 하는 방법은 다음과 같다.

 

[root] /usr/baropam > wget http://nuriapp.com/download/libpam_baro_auth-x.x.tar

 

BaroPAM 인증 모듈의 다운로드가 완료되면 tar 파일의 압축을 해제하는 방법은 다음과 같다.

 

[root] /usr/baropam > tar -xvf libpam_baro_auth-x.x.tar

 

BaroPAM 인증 모듈의 압축을 해제하면 baropam 디렉토리에 다음과 같은 BaroPAM 관련 모듈이 생성된다.

 

[root] /usr/baropam > ls -al
합계 180
drwxrwxrwx  7 root   root   4096  8 23 09:59 .
drwxr-xr-x 17 root   root   4096  2 10  2017 ..
-r--r--r--  1 root   root      8  3 24  2021 .baro_acl
-r--r--r--  1 root   root    305  7  2 14:41 .baro_auth
-r--r--r--  1 root   root    290  6 30 12:55 .baro_curl
-rwxr-xr-x  1 root   root  69149  4  6 19:12 baro_auth
-rwxr-xr-x  1 root   root  65072  6 29 16:36 baro_curl
drwxr-xr-x  2 root   root   4096  7 20  2021 jilee
-rwxr-xr-x  1 root   root 152649  6  9 08:19 pam_baro_auth.so
-rwxr-xr-x  1 root   root 116158  6 30 12:54 pam_baro_curl.so
-rw-r--r--  1 root   root    150  6 29 16:29 setcurl.sh
-rw-r--r--  1 root   root    221  6 27 15:59 setenv.sh

 

 

3.3 BaroPAM 환경 설정 파일 생성

 

1) PAM 인증(.baro_auth)

 

BaroPAM 환경 설정 파일은 baro_auth 프로그램을 실행하여 반드시 생성하는데, BaroPAM 인증 모듈의 디렉토리인 /usr/baropam 밑에 위치 하도록 한다.

 

형식)

baro_auth -r rate_limit -R rate_time -t cycle_time –c corr_time –k key_method –e encrypt_flag -H hostname -A acl_type -a acl_filename -S secure_key -s filename

 

BaroPAM 환경설정 파일의 설정 옵션에 대한 내용은 다음과 같다.

 

옵션 설명 설정값 비고
-r 일회용 인증키의 제한횟수(1~10) 3  
-R 일회용 인증키의 제한시간(, 15~600) 30  
-t 일회용 인증키의 인증주기(, 3~60) 30  
-c 일회용 인증키의 보증오차시간()으로 카드를 사용하는 경우 설정 0  
-k 일회용 인증키의 인증방식(app1, app256, app384, app512: , card1, card256, card384, card512: 인증카드). app512  
-e 환경설정 파일의 암호화 여부(yes or no) no  
-H 서버의 호스트명(uname –n) nurit.co.kr  
-A 2차 인증에서 허용(allow) 또는 제외(deny)할지 선택 deny  
-a 2차 인증에서 허용(allow) 또는 제외(deny)할 계정에 대한 ACL 파일명(파일 접근권한은 444) /usr/baropam/.baro_acl  
-S 반드시 벤더에서 제공하는 Secure key(라이선스 키) jIqIcHbVqdpj7b4PzBpM2DiIeBvmHFV/  
-s BaroPAM 환경설정 파일을 생성할 디렉토리를 포함한 파일명 /usr/baropam/.baro_auth  

 

주의) –s 옵션의 filenameBaroPAM 환경설정 파일을 생성할 디렉토리를 포함한 파일명(파일 접근권한은 444)이며, 설정한 서버의 호스트명(hostname)이 맞지 않는 경우 BaroPAM이 정상적으로 작동되지 않을 수 있으니, 호스트명(hostname)가 변경되는 경우 반드시 환경 설정의 해당 항목에 반영해야 한다.

 

사용 예)

[root] /usr/baropam > ./baro_auth -r 3 -R 30 -t 30 –c 0 –k app512 –e no -H nurit.co.kr -A deny -a /usr/baropam/.baro_acl -S jIqIcHbVqdpj7b4PzBpM2DiIeBvmHFV/ -s /usr/baropam/.baro_auth

 

만약, 계정마다 BaroPAM 환경 설정파일을 각각 설정하는 경우 해당 계정으로 접속하여 작업을 진행한다.(Not root)

 

[root] /usr/baropam > ./baro_auth -r 3 -R 30 -t 30 –c 0 –k app512 –e no -H nurit.co.kr -A deny -a ~/.baro_acl -S jIqIcHbVqdpj7b4PzBpM2DiIeBvmHFV/ -s ~/.baro_auth

 

1) Your emergency scratch codes are :

 긴급 스크래치 코드는 일회용 인증키 생성기인 BaroPAM 앱을 사용할 수 없을 때 분실한 경우를 대비하여 SSH 서버에 다시 액세스하는데 사용할 수 있는 접속이 가능한 Super 인증키 이므로 어딘가에 적어 두는 것이 좋다.

 

2) 다음에 나오는 물음에 대해서는 모두 "y"를 입력한다.

   중간자(man-in-the-middle) 공격을 예방할 것인가? y

   같은 일회용 인증키는 하나의 계정 외에 다른 계정에도 로그인이 가능하게 할 것인가? y

   일회용 인증키의 제한 시간을 30초로 지정할 것인가? y

 

BaroPAM 환경 설정 파일인 .baro_auth에 설정한 내용은 다음과 같다.

 

[root] /usr/baropam > cat .baro_auth
" AUTH_KEY
" RATE_LIMIT 3 30
" KEY_METHOD app512
" CORR_TIME 0
" CYCLE_TIME 30
" SECURE_KEY jIqIcHbVqdpj7b4PzBpM2DiIeBvmHFV/
" ACL_NAME /usr/baropam/.baro_acl
" ACL_TYPE deny
" HOSTNAME nurit.co.kr
" WINDOW_SIZE 17
" DISALLOW_REUSE
33458936
19035576
15364353
54649370
84342192

 

BaroPAM 환경설정 파일인 .baro_auth의 설정 항목에 대한 내용은 다음과 같다.

 

항목 설명 설정값 비고
AUTH_KEY 인증 구분자(고정)    
RATE_LIMIT 일회용 인증키의 제한횟수(1~10), 제한시간(, 15~600) 3 30  
KEY_METHOD 일회용 인증키의 인증방식(app1, app256, app384, app512: , card1, card256, card384, card512: 인증카드) app512  
CORR_TIME 일회용 인증키의 보증오차시간() 0  
CYCLE_TIME 일회용 인증키의 인증주기(, 3~60) 30  
SECURE_KEY 반드시 벤더에서 제공하는 Secure key(라이선스 키) jIqIcHbVqdpj7b4PzBpM2DiIeBvmHFV/  
HOSTNAME 서버의 호스트명(uname –n) nurit.co.kr  
ACL_TYPE 2차 인증에서 허용(allow) 또는 제외(deny) 구분 deny  
ACL_NAME 2차 인증에서 허용 또는 제외할 계정에 대한 ACL Filename(파일 접근권한은 444) /usr/baropam/.baro_acl  
WINDOW_SIZE 현재 시간을 기준으로 일회용 인증키의 보정시간(-7~7) 17  
DISALLOW_REUSE
or
ALLOW_REUSE
중간자(man-in-the-middle) 공격을 예방할 경우는 "DISALLOW_REUSE"을 설정한 경우 일회용 인증키의 인증주기 동안은 다른 사용자가 로그인 할 수 없으며, 만약 허용할 경우는 "ALLOW_REUSE"을 설정한다. DISALLOW_REUSE  

 

 

2) cURL 인증(.baro_curl)

 

curl 의 명칭은 "client URL" 을 대표하는 것으로 1997년에 처음 출시되었다. 즉 클라이언트가 스크립트로써 서버에 데이터를 요청하는 것으로 BaroPAM curlhttp/https 되어 있는 인증 사이트를 호출하여 인증을 요청한다.

 

BaroPAM 환경 설정 파일은 baro_curl 프로그램을 실행하여 반드시 생성하는데, BaroPAM 인증 모듈의 디렉토리인 /usr/baropam 밑에 위치 하도록 한다.

 

형식)

baro_curl -r rate_limit -R rate_time -t cycle_time –k key_method –e encrypt_flag -H hostname –u auth_url -s filename

 

BaroPAM 환경설정 파일의 설정 옵션에 대한 내용은 다음과 같다.

  

옵션 설명 설정값 비고
-r 일회용 인증키의 제한횟수(1~10) 3  
-R 일회용 인증키의 제한시간(, 15~600) 30  
-t 일회용 인증키의 인증주기(, 3~60) 30  
-k 일회용 인증키의 인증방식(app1, app256, app384, app512: , card1, card256, card384, card512: 인증카드). app512  
-e 환경설정 파일의 암호화 여부(yes or no) no  
-H 서버의 호스트명(uname n) nurit.co.kr  
-u 호출할 URL로 호스트명(hostname), 사용자 계정(username), 인증주기(cycle_time), 일회용 인증키(auth_key) 등의 파라미터가 포함되어 호출 http://1.23.456.789/baropam/web/result_curl.jsp?  
-s BaroPAM 환경설정 파일을 생성할 디렉토리를 포함한 파일명 /usr/baropam/.baro_curl  

  

주의) –s 옵션의 filenameBaroPAM 환경설정 파일을 생성할 디렉토리를 포함한 파일명(파일 접근권한은 444)이며, 설정한 서버의 호스트명(hostname)이 맞지 않는 경우 BaroPAM이 정상적으로 작동되지 않을 수 있으니, 호스트명(hostname)가 변경되는 경우 반드시 환경 설정의 해당 항목에 반영해야 한다.

 

사용 예)

[root] /usr/baropam > ./baro_curl -r 3 -R 30 -t 30 –k app512 –e no -H nurit.co.kr -u http://1.23.456.789/baropam/web/result_curl.jsp? -s /usr/baropam/.baro_curl

 

1) 다음에 나오는 물음에 대해서는 모두 "y"를 입력한다.

   중간자(man-in-the-middle) 공격을 예방할 것인가? y

   같은 일회용 인증키는 하나의 계정 외에 다른 계정에도 로그인이 가능하게 할 것인가? y

   일회용 인증키의 제한 시간을 30초로 지정할 것인가? y

 

BaroPAM 환경 설정 파일인 .baro_curl에 설정한 내용은 다음과 같다.

 

[root] /usr/baropam > cat .baro_curl
" AUTH_KEY
" RATE_LIMIT 3 30
" AUTH_URL http://1.23.456.789/baropam/web/result_curl.jsp?
" KEY_METHOD app512
" CYCLE_TIME 30
" HOSTNAME baropam
" WINDOW_SIZE 17
" DISALLOW_REUSE

 

BaroPAM 환경설정 파일인 .baro_curl의 설정 항목에 대한 내용은 다음과 같다.

  

항목 설명 설정값 비고
AUTH_KEY 인증 구분자(고정)    
RATE_LIMIT 일회용 인증키의 제한횟수(1~10), 제한시간(, 15~600) 3 30  
AUTH_URL 호출할 URL로 호스트명(hostname), 사용자 계정(username), 인증주기(cycle_time), 일회용 인증키(auth_key) 등의 파라미터가 포함되어 호출 http://1.23.456.789/baropam/web/result_curl.jsp?  
KEY_METHOD 일회용 인증키의 인증방식(app1, app256, app384, app512: , card1, card256, card384, card512: 인증카드) app512  
CYCLE_TIME 일회용 인증키의 인증주기(, 3~60) 30  
HOSTNAME 서버의 호스트명(uname n) nurit.co.kr  
DISALLOW_REUSE
or
ALLOW_REUSE
중간자(man-in-the-middle) 공격을 예방할 경우는 "DISALLOW_REUSE"을 설정한 경우 일회용 인증키의 인증주기 동안은 다른 사용자가 로그인 할 수 없으며, 만약 허용할 경우는 "ALLOW_REUSE"을 설정한다. DISALLOW_REUSE  

  

 

3.4 BaroPAM 환경 설정

 

1) PAM 인증

 

BaroPAM 모듈을 설정하기 위해서 radiud 파일에 설정하는 방법은 다음과 같이 최 상단에 입력해 준다.

 

[root] /usr/baropam > vi /etc/pam.d/radiusd
auth       required     /usr/baropam/pam_baro_auth.so forward_pass secret=/usr/baropam/.baro_auth encrypt=no

 

참고로 secret 파라미터는 BaroPAM 환경설정 파일명, encrypt 파라미터는 BaroPAM 환경설정 파일을 암복호 플래그(yes or no) 설정한다.

 

만약, 계정마다 BaroPAM 환경 설정파일을 각각 설정하는 경우 BaroPAM 모듈을 설정하기 위해서 sshd 파일에 설정하는 방법은 다음과 같이 최 상단에 입력해 준다.

 

[root] /usr/baropam > vi /etc/pam.d/radiusd
#%PAM-1.0
auth       required     /usr/baropam/pam_baro_auth.so forward_pass secret=${HOME}/.baro_auth encrypt=no

 

filezilla 처럼 "Interactive process"가 불가능한 프로그램들을 위해서는 PAM에서 forward_pass 옵션을 사용하여 암호 입력 시에 암호와 일회용 인증키를 같이 입력하도록 하는 수 밖에 없다. 이 경우, openssh clientWindows RDP(Remote Desktop Protocol), Radius, filezilla 등 모두 이렇게 입력을 하는 수 밖에 없다.

 

 

forward_pass를 이용하여 암호 입력창(Password:)에 암호와 같이 일회용 인증키를 입력할 경우, 암호를 먼저 입력하고 공백 없이 이어서 일회용 인증키를 입력하면 된다. 예를 들어 암호가 "baropam" 이고 일회용 인증키 "123456" 이라면 "baropam123456"으로 입력하면 됩니다.

 

forward_pass를 이용하면 인증을 필요로 하는 대부분의 서비스에 2-factor 인증을 가능하게 할 수 있다.

 

 

2) cURL 인증

 

BaroPAM 모듈을 설정하기 위해서 sshd, su, sudo 파일 등에 설정하는 방법은 다음과 같이 최 상단에 입력해 준다.

 

[root] /usr/baropam > vi /etc/pam.d/radiusd
auth       required     /usr/baropam/pam_baro_curl.so forward_pass secret=/usr/baropam/.baro_curl encrypt=no

 

참고로 secret 파라미터는 BaroPAM 환경설정 파일명, encrypt 파라미터는 BaroPAM 환경설정 파일을 암복호 플래그(yes or no) 설정한다.

 

filezilla 처럼 "Interactive process"가 불가능한 프로그램들을 위해서는 PAM에서 forward_pass 옵션을 사용하여 암호 입력 시에 암호와 일회용 인증키를 같이 입력하도록 하는 수 밖에 없다. 이 경우, openssh clientWindows RDP(Remote Desktop Protocol), Radius, filezilla 등 모두 이렇게 입력을 하는 수 밖에 없다.

 

 

forward_pass를 이용하여 암호 입력창(Password:)에 암호와 같이 일회용 인증키를 입력할 경우, 암호를 먼저 입력하고 공백 없이 이어서 일회용 인증키를 입력하면 된다. 예를 들어 암호가 "baropam" 이고 일회용 인증키 "123456" 이라면 "baropam123456"으로 입력하면 됩니다.

 

forward_pass를 이용하면 인증을 필요로 하는 대부분의 서비스에 2-factor 인증을 가능하게 할 수 있다.

 

 

3) ACL(Access Control list) 설정

 

1) PAM 인증인 경우 BaroPAM 모듈 사용 시 2차 인증에서 제외할 계정에 대한 ACL에 제외 해야 하는 경우 BaroPAM 환경 설정 시 설정한 디렉토리에 ACL 파일을 생성한 후 제외할 계정을 다음과 같이 입력한다. (.baro_acl에 대한 파일 접근권한을 444로 설정해야 한다.)

 

[root] /usr/baropam > vi .baro_acl
barokey
baropam

 

 

4) NTP(Network Time Protocol) 설정

 

정보자산의 시간이 현재 시간과 다를 경우 일회용 인증키와 매칭이 되지 않아 일회용 인증키가 맞질 않으므로 시간을 같게 초기화 하는 방법은 crontab에 다음과 같이 설정한 후 crontab restart하면 된다.

 

#Time setting
11 4 * * * /usr/bin/rdate -s time.simplexi.com; /sbin/hwclock --systohc
or
11 4 * * * /usr/bin/rdate -s time.bora.net;

 

정보자산의 시간이 현재 시간과 다를 경우 일회용 인증키와 매칭이 되지 않아 일회용 인증키가 맞질 않으므로 서버를 설치할 때 시간대(타임존;Timezone)를 맞추지 않으면, 컴퓨터 시계가 미국 태평양 시간인 PST로 나온다. (서머타임 기간에는 PDT.) 즉 캘리포니아 시간으로 나온다. 이것을 한국 표준시인 KST로 다음과 같이 변경해야 한다.

 

> ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
> date 112212292017.00

 

최근에는 정보자산에 대한 시간 동기화(타임서버 시간 동기화)하는 방법으로 NTP(Network Time Protocol)을 이용하여 루트 계정에서 시스템의 시각을 현재 시각으로 설정할 수 있다.

 

NTP를 사용하기 위해서는 기본적으로 NTP 패키지가 반드시 설치되어 있어야 한다. 설치 확인은 다음의 명령어를 실행하여 확인한다. 만약, 설치되어 있지 않으면 Redhat, CentOS 8 이하 버젼은 "yum install ntp" 그외는 "sudo apt-get install ntp" 명령어로 설치하면 된다.

 

[root]# rpm -qa | grep ntp
ntp-4.2.2p1-18.el5.centos
chkfontpath-1.10.1-1.1

 

ntpd 서비스를 서버 부팅 시 시작프로그램에 등록 및 ntp 활성화 여부 확인은 다음과 같은 명령어로 확인 할 수 있다.

 

[root]# chkconfig ntpd on
[root]# chkconfig --list | grep ntp
ntpd            0:해제  1:해제  2:활성  3:활성  4:활성  5:활성  6:해제

 

chkconfig 이용하여 서버 부팅시 ntpd 데몬 활성화 여부 확인 3, 5 level off(해제) 가 되어 있으면 자동 활성화 되지 않는다. 자동 활성화 하기 위해서는 3, 5 on(활성)으로 다음과 같은 명령어로 변경해야 한다.

 

[root]# chkconfig --level 3 ntpd on
[root]# chkconfig --level 5 ntpd on

 

우리나라에서 운영되고 있는 NTP 서버는 다음과 같다.

 

server kr.pool.ntp.org
server time.bora.net
server time.kornet.net

 

우리나라에서 운영되고 있는 NTP 서버를 ntpd 데몬 설정을 위한 설정 파일인 "/etc/ntp.conf"에 다음과 같이 설정한다.

 

[root]# vi /etc/ntp.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
#server 3.centos.pool.ntp.org
server kr.pool.ntp.org iburst
server time.bora.net   iburst
server time.kornet.net iburst

 

iburst 옵션은 일종의 옵션 설정으로써 동기화 하는데 걸리는 시간을 짧게 줄여주는 옵션임.

 

ntpd 데몬 설정을 위한 설정이 끝나면 반드시 NTP 설정이 제대로 추가되었는지 확인한 후 NTP 데몬의 Restart 작업이 반드시 필요하다.

 

[root]# /etc/init.d/ntpd restart
ntpd를 종료 중: [  OK  ]
ntpd ()를 시작 중: [  OK  ]

 

ntpd 시간 확인은 다음과 같은 명령어로 확인할 수 있다.

 

[root]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 static.betaidc. 106.247.248.106  3 u    7   64    1    2.884  287.718   0.001
 time.bora.net   .INIT.          16 u    -   64    0    0.000    0.000   0.000
 183.110.225.61  .INIT.          16 u    -   64    0    0.000    0.000   0.000
 LOCAL(0)        .LOCL.          10 l    4   64    1    0.000    0.000   0.001

* 표시된 ip 가 현재 시간을 가져오고 있는 ntp 서버임

 

NTP를 사용하기 위해서는 기본적으로 NTP 패키지가 반드시 설치되어 있어야 한다. 설치 확인은 다음의 명령어를 실행하여 확인한다. 만약, 설치되어 있지 않으면 Redhat, CentOS 8 이상 버젼은 "yum install chrony" 명령어로 설치하면 된다.

 

[root@baropam ~]# rpm -qa | grep chrony
chrony-3.5-1.el8.x86_64

 

우리나라에서 운영되고 있는 NTP 서버는 다음과 같다.

 

server kr.pool.ntp.org
server time.bora.net
server time.kornet.net

 

우리나라에서 운영되고 있는 NTP 서버를 ntpd 데몬 설정을 위한 설정 파일인 "/etc/chrony.conf"에 다음과 같이 설정한다.

 

[root@baropam ~]# vi /etc/chrony.conf
 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst
server kr.pool.ntp.org iburst
server time.bora.net   iburst
server time.kornet.net iburst
 
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
 
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
 
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
 
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
 
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
 
# Allow NTP client access from local network.
allow 192.168.0.0/16
 
# Serve time even if not synchronized to a time source.
#local stratum 10
 
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
 
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
 
# Specify directory for log files.
logdir /var/log/chrony
 
# Select which information is logged.
#log measurements statistics tracking

 

ntpd 데몬 설정을 위한 설정이 끝나면 반드시 NTP 설정이 제대로 추가되었는지 확인한 후 NTP 데몬의 Restart 작업이 반드시 필요하다. (chrony 서비스 시작 및 부팅시 구동 등록)

 

[root@baropam ~]# sudo systemctl enable chronyd
[root@baropam ~]# sudo systemctl restart chronyd

 

ntpd 시간 확인은 다음과 같은 명령어로 확인할 수 있다.

 

시간을 받아오는 서버 리스트 / chrony.conf 파일에 등록한 server 리스트)

 

[root@baropam ~]# chronyc sources
210 Number of sources = 2
MS Name/IP address         Stratum Poll Reach LastRx Last sample              
===============================================================================
^* ec2-54-180-134-81.ap-nor>     2   6   377    43   -349us[-1059us] +/-   24ms
^- time.bora.net                 2   6   377    42  +1398us[+1398us] +/-   90ms

 

시간을 받아 오는 서버 정보)

 

[root@baropam ~]# chronyc tracking
Reference ID    : 36B48651 (ec2-54-180-134-81.ap-northeast-2.compute.amazonaw)
Stratum         : 3
Ref time (UTC)  : Sun Mar 22 07:07:43 2020
System time     : 0.000130027 seconds slow of NTP time
Last offset     : -0.000710122 seconds
RMS offset      : 0.000583203 seconds
Frequency       : 19.980 ppm fast
Residual freq   : +0.142 ppm
Skew            : 3.235 ppm
Root delay      : 0.013462566 seconds
Root dispersion : 0.017946836 seconds
Update interval : 65.0 seconds
Leap status     : Normal

 

시간 상태 및 동기화 등 정보 확인)

 

[root@baropam ~]# timedatectl status
               Local time: Sun 2020-03-22 16:08:45 KST
           Universal time: Sun 2020-03-22 07:08:45 UTC
                 RTC time: Sun 2020-03-22 07:08:44
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

 

 

5) BaroPAM 앱과 BaroPAM 웹 사이트

  

일회용 인증키 발생기인 BaroPAM 어플의 안드로이드 폰용 다운로드(https://play.google.com/store/apps/details?id=com.baro.pam) 구글의 "Play 스토어"에서 아이폰 용은 애플의 "App store"에서 가능하며, 설치는 일반 어플의 설치와 동일하다.

 

 

BaroPAM 어플(안드로이드 폰용과 아이폰 용)에 문제가 발생 시 서비스의 중단이 발생하지 않토록 BaroPAM 웹 사이트(www.baropam.com)를 통해서도 서비스를 제공한다.

 

 

 

 

4. FreeRADIUS 연동 테스트

 

4.1 테스트할 계정 생성

 

테스트할 로컬 계정을 다음과 같이 생성한다.

 

[root@localhost ~]# useradd raduser
[root@localhost ~]# passwd raduser
Changing password for user raduser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

 

) 로컬 계정을 생성하는 쉘 스크립트(auths=pam인 경우) - setuser.sh

 

#!/bin/sh
 
export BAROPAM_HOME=/usr/baropam;
 
useradd -m -s /bin/bash $1
 
echo '$2' | passwd -stdin $1
 
export ACC_HOME=/home/$1
 
cp $BAROPAM_HOME/.baro_auth $ACC_HOME/.baro_auth
 
sed -i "s/01012341234/$3/g" $ACC_HOME/.baro_auth

 

로컬 계정을 생성하는 쉘 스크립트(setuser.sh) 실행 시 파라미터는 다음과 같다.

$1 : 생성 로컬 계정

$2 : 로컬 계정의 비밀번호

$3 : 로컬 계정의 폰번호

 

[root@localhost ~]# sh setuser.sh nurit baropam 01027714076

 

) 로컬 계정을 생성하는 쉘 스크립트(auth=http인 경우) - setuser.sh

 

#!/bin/sh
 
export BAROPAM_HOME=/usr/baropam;
 
useradd -m -s /bin/bash $1
 
echo '$2' | passwd -stdin $1

 

로컬 계정을 생성하는 쉘 스크립트(setuser.sh) 실행 시 파라미터는 다음과 같다.

$1 : 생성 로컬 계정

$2 : 로컬 계정의 비밀번호

 

[root@localhost ~]# sh setuser.sh nurit baropam

 

 

4.2 FreeRADIUS 데몬 디버그 모드로 실행

 

ssh 세션을 열고 디버그 모드에서 radiusd를 다음과 같이 실행한다.

 

[root@localhost ~]# radiusd -X

 

디버그 모드에서 radiusd를 실행 시 다음과 같은 오류가 발생하면

 

Then run radiusd -X but I have this error:
 
Failed reading private key file /etc/raddb/certs/server.pem:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
rlm_eap_tls: Failed initializing SSL context
rlm_eap (EAP): Failed to initialise rlm_eap_tls
/etc/raddb/mods-enabled/eap[17]: Instantiation failed for module "eap"

 

다음과 같은 작업을 진행한 후 radiusd를 다음과 같이 실행한다.

 

[root@localhost ~]# cd  /etc/raddb/certs
[root@localhost ~]# ./bootstrap

 

첫 번째 ssh 세션으로 전환하고 테스트 한다.

 

형식)

radtest <username> (<pasword><verification code>) localhost 0 baropam

 

테스트)

[root@localhost ~]# radtest adtom@eden.com your_password077719 localhost 0 testing123
Sent Access-Request Id 121 from 0.0.0.0:60925 to 127.0.0.1:1812 length 100
         User-Name = "adtom@eden.com"
         User-Password = "your_password077719"
         NAS-IP-Address = 10.0.0.199
         NAS-Port = 0
         Message-Authenticator = 0x00
Cleartext-Password = "your_password077719"
Received Access-Accept Id 121 from 127.0.0.1:1812 to 0.0.0.0:0 length 20

 

BaroPAM으로 FreeRADIUS 테스트를 다음과 같이 실행한다.

 

[root@localhost ~]# radtest root baropam024747 localhost 0 baropam
Sent Access-Request Id 243 from 0.0.0.0:39668 to 127.0.0.1:1812 length 74
        User-Name = "root"
        User-Password = "baropam903481"
        NAS-IP-Address = 10.0.2.15
        NAS-Port = 0
        Message-Authenticator = 0x00
        Cleartext-Password = "baropam903481"
Received Access-Accept Id 243 from 127.0.0.1:1812 to 127.0.0.1:39668 length 20

 

 

4.2 FreeRADIUS 데몬 실행

 

FreeRADIUS 데몬인 radiusd를 다음과 같이 백그라운드로 실행한다.

 

[root@localhost ~]# radiusd -s &
[1] 1961

 

FreeRADIUS 데몬인 radiusd가 정상적으로 기동되었는지 다음과 같이 확인한다.

 

[root@localhost ~]# ps -ef|grep radiusd
root        1961    1818  0 14:11 pts/1    00:00:00 radiusd -s
root        1964    1818  0 14:11 pts/1    00:00:00 grep --color=auto radiusd

 

FreeRADIUS 데몬인 radiusd가 사용하는 UDP 포트인 1812를 다음과 같이 확인한다.

 

[root@localhost ~]# netstat -an | grep 1812
udp        0      0 127.0.0.1:18120         0.0.0.0:*                         
udp        0      0 0.0.0.0:1812            0.0.0.0:*                         
udp6       0      0 :::1812                 :::*

 

FreeRADIUS를 연동하여 BaroPAM에서 인증한 로그는 다음과 같이 확인한다.

 

[root@localhost ~]# tail –f /var/log/secure
Mar 26 13:54:11 localhost radiusd(pam_baro_auth)[1857]: Try to update RATE_LIMIT line.[3 30 1616734451]
Mar 26 13:56:46 localhost radiusd(pam_baro_auth)[1857]: Try to update RATE_LIMIT line.[3 30 1616734606]
Mar 26 14:00:48 localhost radiusd(pam_baro_auth)[1934]: Try to update RATE_LIMIT line.[3 30 1616734848]
Mar 26 14:00:48 localhost radiusd(pam_baro_auth)[1934]: Invalid verification code
Mar 26 14:00:48 localhost radiusd[1934]: pam_unix(radiusd:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=scjoo1
Mar 26 14:01:13 localhost radiusd(pam_baro_auth)[1934]: Try to update RATE_LIMIT line.[3 30 1616734873]
Mar 26 14:01:36 localhost radiusd(pam_baro_auth)[1934]: Try to update RATE_LIMIT line.[3 30 1616734873 1616734896]
Mar 26 14:02:15 localhost radiusd(pam_baro_auth)[1934]: Try to update RATE_LIMIT line.[3 30 1616734935]

 

 

4.3 FreeRADIUS 데몬 종료

 

먼저 FreeRADIUS 데몬인 radiusd가 실행되었는지 다음과 같이 확인한다.

 

[root@localhost ~]# ps -ef|grep radiusd
root        1961    1818  0 14:11 pts/1    00:00:00 radiusd -s
root        1964    1818  0 14:11 pts/1    00:00:00 grep --color=auto radiusd

 

FreeRADIUS 데몬인 radiusd의 프로세스 ID(1961)를 확인 한 후 다음과 같이 종료한다.

 

[root@localhost ~]# kill -9 1961

 

FreeRADIUS 관련 로그 파일: /var/log/radius/ radius.log

 

CentOS를 대체할 알마리눅스

https://almalinux.org

https://repo.almalinux.org/almalinux/8.3-beta/isos/x86_64/

 

 

 

5. About BaroPAM

 

 

Version 1.0 - Official Release - 2016.12.1

Copyright ⓒ Nurit corp. All rights reserved.

http://www.nurit.co.kr

 

제 조 사 : 주식회사 누리아이티
등록번호 : 258-87-00901
대표이사 : 이종일
대표전화 : 02-2665-0119(영업문의/기술지원)
이 메 일 : mc529@nurit.co.kr
주    소 : 서울시 강서구 마곡중앙2로 15, 913호(마곡동, 마곡테크노타워2)