0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AWS ClientVPN 接続手順

Posted at

概要

AWS ClientVPNを急遽使用することになったので、構築手順をメモとしてまとめます。

構成図

構成図は以下の通りです。

名称未設定.jpg

手順

  • ACMに自己証明書をインポートする。

公式手順通りに証明書の発行を行います。

$ git clone https://github.com/OpenVPN/easy-rsa.git
$ cd easy-rsa/easyrsa3
$ ./easyrsa init-pki
$ ./easyrsa build-ca nopass
$ ./easyrsa build-server-full server nopass
$ ./easyrsa build-client-full client1.domain.tld nopass

作成した以下証明書・秘密鍵を任意のディレクトリに保存し、ACMにインポートを行います。
公式手順はCLIですが、今回はGUI画面からインポートを行っています。

ca.crt     server.crt server.key  client1.domain.tld.crt        client1.domain.tld.key

スクリーンショット 2021-02-06 17.48.48.png

  • ClientVPN Gatewayの作成

クライアント側のIPv4 CIDR領域はVPC内のネットワークと重複しないよう設定します。

  • クライアントからの受信を承認

認証タブの受信の承認を押下し、クライアントが接続できるネットワークの範囲を設定します。
宛先ネットワークについてはVPC領域全てを設定し、個別設定などは特に行っておりません。

スクリーンショット 2021-02-06 18.01.03.png

  • 設定ファイルの修正

クライアント設定のダウンロードを押下し、ダウンロードした設定ファイルを修正します。
接続先ホスト名に任意の文字列を加え、証明書・秘密鍵の内容を追記します。

remote test.xxxxxxxxxx.amazonaws.com 443
.
.
.
<ca>
xxxxxxxxxxx
</ca>

<cert>
xxxxxxxxxxx
</cert>

<key>
xxxxxxxxxxx
</key>

reneg-sec 0
  • 任意のClientVPNソフトを使用し接続確認

今回はTunnelblickを使用し、VPN接続後インスタンスにSSH接続を行います。
インスタンスのセキュリティグループは、VPNに割り当てられるクライアントIPアドレスのCIDR領域を予め許可しておく必要があります。

$ ssh ec2-user@10.0.1.217 -i ~/.ssh/xxxxx.pem
Last login: Sat Feb  6 08:34:34 2021 from ip-10-0-1-39.ap-northeast-1.compute.internal

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-10-0-1-217 ~]$

プライベートIPアドレスで接続できることが確認できました。

終わりに

エンドユーザに影響するサービスではないので、本番環境も自己証明書で運用しても良いと思っています。
今回は簡単な手順なので、セキュリティグループなどは適宜見直す必要があります。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?