작성일 댓글 한 개

openvpn 인증방식을 OTP로 변경하기

openvpn에 인증할 때 otp방식을 사용해보자.
이미 openvpn을 잘 운영하고 있는 상태에서 인증부분만 otp방식으로 변경한다고 가정한다.
centos6.3 에서 테스트했다.

otp솔루션은 google-authenticator를 이용할 것이다.


google-authenticator를 다운로드 받아서 컴파일을 하자.
컴파일 할 때 Makefile 열어서 최상단에 아래 구문을 추가하자.

1
LDFLAGS="-lpam"


openvpn의 server.conf을 열어서 인증 플러그인을 부분을 수정하자.

1
plugin /usr/local/openvpn/openvpn-auth-pam.so openvpn

인증은 openvpn이라는 놈을 사용하도록 했으므로 /etc/pam.d/openvpn 파일을 아래와 같이 만들자.

1
2
3
4
5
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth    required     pam_google_authenticator.so
account    required     pam_nologin.so
account    include      system-auth



vpn을 접속할 계정으로 아래 명령을 실행하자.

1
2
root # su - vpnuser
[vpnuser@vpn ~]$ google-authenticator


그러면 이렇게 뜬다.

1
2
3
4
5
6
7
8
9
10
Your new secret key is: ZUTR5Y3WEHRDMRDX
Your verification code is 264476
Your emergency scratch codes are:
  21748738
  88769415
  51651509
  95973574
  99309175
Do you want me to update your "~/.google_authenticator"

URL은 웹브라우저에서 접속하면 QR코드가 뜨는데 클라이언트에서 접속할 때 써먹을 것이다.

그리고 아래와 같이 세번의 질문이 뜬다.

1
2
3
Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n)

y를 선택


1
2
3
4
5
By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n)


n를 선택

1
2
3
4
If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n)

y를 선택


서버쪽 세팅은 끝났다.
openvpn을 (재)시작한다.



이제 아이폰은 앱스토어에서 google Authenticator를 다운받고, 안드로이드폰에서는 google OTP를 다운받자.

위의 URL에 접속하면 QR코드가 뜨는데 google Authenticator를 실행해서 QR코드를 찍으면 된다.
혹은 직접 입력하면 되는데 계정은 [email protected], 키는 ZUTR5Y3WEHRDMRDX 이런식으로 입력하면 된다.

이제 클라이언트에서 openvpn접속 할 때 id는 vpnuser, pw는 otp키 6자리를 사용하면 된다.



openvpn 인증방식을 OTP로 변경하기”에 대한 1개의 의견

  1. 오~ 이런게 다 있었네

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다