All Products
Search
Document Center

VPN Gateway:Establish an SSL-VPN connection with AD authentication

Last Updated:Sep 16, 2026

SSL-VPN with two-factor authentication enhances security by requiring clients to authenticate first with an SSL client certificate, and then with a username and password verified by identity as a service (IDaaS). When you use IDaaS authentication, you can bind an Active Directory (AD) server to enable AD-based logon. This topic describes how to use SSL-VPN two-factor authentication to connect a client to a Virtual Private Cloud (VPC) through an AD server. Once connected, the client can access resources within the VPC.

Scenario

image

In this scenario, a company has a VPC in the China (Hangzhou) region where applications are deployed on ECS instances. For business purposes, employees on business trips need to remotely access these resources. For security, the company requires all employees to authenticate through its on-premises Active Directory (AD) server before accessing resources in the VPC.

The company can use the SSL-VPN feature of a VPN gateway and enable two-factor authentication for the SSL-VPN connection. The company can also configure an IDaaS application to perform AD authentication. When an employee attempts to establish an SSL-VPN connection to Alibaba Cloud, the employee must first pass authentication with an SSL client certificate and then AD authentication, which is handled by an IDaaS EIAM instance. The IDaaS EIAM instance sends the employee's credentials to the company's AD server for verification and returns the result. After successful verification, the employee can establish an SSL-VPN connection to Alibaba Cloud and access resources in the VPC.

Prerequisites

  • You have created a VPC in the China (Hangzhou) region and deployed applications on ECS instances in the VPC. For more information, see Set up an IPv4 VPC.

    Ensure the security group rules for the ECS instances allow clients to access the required cloud resources. For more information, see Query security group rules and Add a security group rule.

  • Make sure that the client can access the internet, and its private CIDR block does not overlap with the private CIDR block of the VPC.

  • You have created an Enterprise Edition IDaaS EIAM instance. For more information, see Manage instances.

    Important
  • You have the public IP address and service port of the AD server.

    In this example, the AD system is deployed on a Windows Server 2022 system. The public IP address is 47.XX.XX.62 and the service port is 389.

  • You have the Base DN of the AD server.

    In this example, the Base DN of the AD server is dc=zxtest,dc=com.

  • You have the DN, username, and password of the administrator on the AD server.

    In this example, the administrator account name is Administrator and the password is 1****2. The DN is cn=Administrator,cn=Users,dc=zxtest,dc=com. For example, in Active Directory Users and Computers, expand the domain node (for example, zxtest.com) and the Users container to locate the Administrator user. The DN is CN=Administrator,CN=Users,DC=zxtest,DC=com.

Procedure

image

Step 1: Bind the AD server

Bind an AD server to the IDaaS EIAM instance to synchronize account information from the AD server. For more information, see Bind AD - Inbound.

In this example, use the default values for all parameters except for the required ones when binding the AD server. The following shows the account information synchronized to the IDaaS EIAM instance from the AD server.

After the synchronization is complete, go to the Accounts tab. In the account list, the Source of the wangwu account is displayed as AD Import, and its status is normal. The Source of other accounts, such as zhangsan and Lisi, is Self-created. This confirms that the AD accounts are successfully synchronized to the IDaaS EIAM instance.

Step 2: Add the SSL-VPN application

  1. Log on to the IDaaS console.

  2. On the EIAM page, find the EIAM instance that you created in Prerequisites, and then in the Actions column, click Console.

  3. In the left-side navigation pane of the EIAM instance, click Application. On the Application page, click Add Application.

  4. On the Add Application page, find the Alibaba Cloud - SSL VPN template and click Add Application.

  5. In the Add Application dialog box, enter a name for the application and click Add.

  6. On the Sign-In tab of the application details page, configure the following parameters and click Save at the bottom of the tab.

    SSO: Keep this feature enabled.

    Grant Types: The default value is Password Grant. For IdP, select the bound AD server. The system uses the AD server to authenticate employees.

    Authorize: Use the default value Manually. This setting requires you to manually authorize specific accounts to access this application. For more information about authorization scopes, see Authorization scope.

  7. Remain on the Sign-In tab and click the Application Authorization tab.

    Grant permissions to the employee accounts that need to establish SSL-VPN connections. For more information, see Application authorization.

Step 3: Create a VPN gateway

  1. Log on to the VPN gateway console.
  2. On the VPN Gateways page, click Create VPN Gateway.

  3. On the VPN Gateway page, configure the VPN gateway as described below, click Buy Now, and complete the payment.

    The following table describes only the parameters that are relevant to this topic. Keep the default values for other parameters. For more information, see Create and manage a VPN Gateway instance.

    Parameter

    Description

    Region

    Select the region where you want to create the VPN Gateway instance. In this example, China (Hangzhou) is selected.

    Note

    Make sure that the VPC and the VPN Gateway instance are in the same region.

    gateway type

    Select the type of VPN gateway that you want to create. In this example, Standard is selected.

    Network Type

    Select the network type of the VPN Gateway instance. In this example, Public is selected.

    tunnel

    The system displays the tunnel modes for IPsec-VPN connections that are supported in the current region.

    VPC

    Select the VPC that you want to connect.

    vSwitch 1

    Select a vSwitch from the VPC.

    • If you select Single-tunnel, you need to specify only one vSwitch.

    • If you select Dual-tunnel, you need to specify two vSwitches.

      After the IPsec-VPN feature is enabled, the system creates an elastic network interface (ENI) for each of the two vSwitches as an interface to communicate with the VPC over an IPsec-VPN connection. Each ENI occupies one IP address in the vSwitch.

    Note
    • The system selects a vSwitch by default. You can change or use the default vSwitch.

    • After a VPN gateway is created, you cannot modify the vSwitch associated with the VPN gateway. You can view the vSwitch associated with the VPN gateway, the zone to which the vSwitch belongs, and the ENI in the vSwitch on the details page of the VPN gateway.

    vSwitch 2

    Select the second vSwitch from the VPC.

    • Specify two vSwitches in different zones in the associated VPC to implement disaster recovery across zones for IPsec-VPN connections.

    • For a region that supports only one zone, disaster recovery across zones is not supported. We recommend that you specify two vSwitches in the zone to implement high availability of IPsec-VPN connections. You can also select the same vSwitch as the first one.

    Note

    If the VPC does not have a second vSwitch, you can create one. For more information, see Create and manage a vSwitch.

    IPsec-VPN

    Specifies whether to enable the IPsec-VPN feature. In this example, select Disable.

    SSL-VPN

    Specifies whether to enable the SSL-VPN feature. In this example, select Enable.

    SSL connections

    Select the maximum number of clients that can connect at the same time.

    Note

    You can configure SSL Connections only after you enable the SSL-VPN feature.

  4. Return to the VPN Gateways page to view the VPN Gateway instance.

    A new VPN Gateway instance is in the Preparing state. After 1 to 5 minutes, the state changes to Normal. The Normal state indicates that the VPN Gateway instance is initialized.

Step 4: Create an SSL server

  1. In the left navigation pane, choose Interconnections > VPN > SSL Servers.

  2. In the top navigation bar, select the region for the SSL server.

    Note

    Make sure that the SSL server and the VPN Gateway instance are in the same region.

  3. On the SSL Server page, click Create SSL Server.

  4. In the Create SSL Server panel, configure the SSL server as described in the following table, and click OK.

    The following table describes only the parameters that are relevant to this topic. Keep the default values for other parameters. For more information, see Create and manage an SSL server.

    Parameter

    Description

    VPN Gateways

    Select the VPN Gateway instance that you created.

    Local Network

    Enter the CIDR block of the VPC that you want to access. In this example, 192.168.0.0/16 is used.

    Client CIDR Block

    Enter the CIDR block that is used by the client to access the VPC. In this example, 10.0.0.0/24 is used.

    Important
    • The subnet mask of the client CIDR block must be 16 to 29 bits in length.

    • The client CIDR block must not overlap with the Local Network, the VPC CIDR block, or any CIDR blocks routed on the client.

    • Use private CIDR blocks such as 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16, or their subnets. To use a public IP range, configure it as a user-defined CIDR block in the VPC for proper routing. VPC FAQ and VPC FAQ.

    • After you create the SSL server, the system adds a route for the client CIDR block to the VPC route table. Do not manually add this route, as it may disrupt SSL-VPN traffic. If a vSwitch is associated with a custom route table, the system does not automatically add the route for the client CIDR block to that custom route table. You must manually add a route entry whose destination CIDR block is the client CIDR block and whose next hop is the VPN gateway. Otherwise, hosts in the CIDR blocks associated with the custom route table cannot communicate with SSL-VPN clients.

    Advanced Settings

    Enable two-factor authentication. This topic uses EIAM 2.0. Keep the default values for the other settings.

    • IDaaS Instance Region: Select China (Hangzhou).

    • IDaaS Instance: Select the EIAM instance that you created in the prerequisites.

    • IDaaS Application: Select the Alibaba Cloud SSL-VPN application that you added.

      Note

      When creating an SSL server in the UAE (Dubai) region, bind an IDaaS EIAM 2.0 instance in the Singapore region to reduce cross-region latency.

Step 5: Create an SSL client certificate

  1. In the navigation pane on the left, choose Interconnections > VPN > SSL Clients.

  2. On the SSL Client page, click Create SSL Client.

  3. In the Create SSL Client panel, enter a name for the SSL client certificate, select the corresponding SSL Server, and then click OK.

  4. On the SSL Client page, find the SSL client certificate that you created and click Download Certificate in the Actions column.

    Save the downloaded SSL client certificate. You will need it to configure the client.

Step 6: Configure the client

Linux client

  1. Open the command-line interface (CLI).

  2. Run the following command to install the OpenVPN client.

    CentOS
    yum install -y openvpn
    mkdir -p /etc/openvpn/conf
    Ubuntu
    apt-get update
    apt-get install -y openvpn
    mkdir -p /etc/openvpn/conf
  3. Extract the downloaded SSL client certificate package and copy the files to the /etc/openvpn/conf/ directory.

  4. Go to the /etc/openvpn/conf/ directory, run the following command, and then enter the username and password. After the client is authenticated by the AD server, an SSL-VPN connection is established.

    openvpn --config /etc/openvpn/conf/config.ovpn --daemon
    [root@iZufxxxmcZ ~]# cd /etc/openvpn/conf
    [root@iZufxxxmcZ conf]# openvpn --config /etc/openvpn/conf/config.ovpn --daemon
    Enter Auth Username: wangwu
    Enter Auth Password: *********
    [root@iZufxxx conf]# ps aux | grep openvpn
    ogt   21148  0.0  0.1  14664  5712 ?        Ss   May10   0:00 openvpn --config /etc/openvpn/conf/config.ovpn --daemon
    root  23249  0.0  0.0  21528   916 pts/0    S+   10:46   0:00 grep --color=auto openvpn

Windows client

  1. Download the OpenVPN client that is compatible with your Windows system version, and complete the installation as prompted by the interface:

  2. Decompress the downloaded SSL client certificate and copy the extracted all files to the OpenVPN configuration directory.

    • Default path: C:\Program Files\OpenVPN\config

    • Note: If you have modified the installation path, copy them to the config folder in your actual installation directory.

    image

  3. Open the config.ovpn file with Notepad and add one line at the end: disable-dco.

    The Data Channel Offload (DCO) feature introduced in OpenVPN 2.6 has compatibility issues on some Windows systems (such as specific versions of Windows 10/11). This configuration is used to disable DCO to resolve the issue of some devices being unable to connect.

    image

  4. Start the OpenVPN client, click Connect, and then enter your username and password. After the client is authenticated by the AD server, an SSL-VPN connection is established.

macOS client (OpenVPN)

  1. Open a command-line window.

  2. If Homebrew is not installed, run the following command to install it.

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Run the following command to install the OpenVPN client.

    brew install openvpn
  4. Extract the downloaded SSL client certificate and copy the files to the configuration directory.

    1. Back up all configuration files in the /usr/local/etc/openvpn folder.

      Important

      The default installation path for OpenVPN may vary based on the macOS version. Make sure to use the actual installation path in the following steps.

    2. Run the following command to delete the OpenVPN configuration files.

      rm /usr/local/etc/openvpn/*
    3. Run the following command to copy the downloaded SSL client certificate to the configuration directory.

      cp cert_location /usr/local/etc/openvpn/

      cert_location is the path to the downloaded SSL client certificate. Example: /Users/example/Downloads/certs6.zip.

  5. Run the following command to extract the certificate.

    cd  /usr/local/etc/openvpn/
    unzip /usr/local/etc/openvpn/certs6.zip
  6. Go to the /usr/local/etc/openvpn/ directory, run the following command, and then enter the username and password to establish an SSL-VPN connection.

    sudo /usr/local/opt/openvpn/sbin/openvpn --config /usr/local/etc/openvpn/config.ovpn

Step 7: Test the connectivity

After completing the preceding steps, the client can remotely access resources in the VPC. The following section describes how to test the connectivity between a Linux client and the VPC.

  1. Open the command-line window on the client.

  2. Run the ping command to access the ECS1 instance in the VPC and verify the connectivity.

    ping <IP address of the ECS1 instance>

    If you receive reply packets like those shown below, the client is successfully connected to the VPC.

    [root@iZuf6         ihcZ conf]# ping 192.168.10.154
    PING 192.168.10.154 (192.168.10.154) 56(84) bytes of data.
    64 bytes from 192.168.10.154: icmp_seq=1 ttl=63 time=11.9 ms
    64 bytes from 192.168.10.154: icmp_seq=2 ttl=63 time=11.7 ms
    64 bytes from 192.168.10.154: icmp_seq=3 ttl=63 time=11.7 ms
    64 bytes from 192.168.10.154: icmp_seq=4 ttl=63 time=11.8 ms
    64 bytes from 192.168.10.154: icmp_seq=5 ttl=63 time=11.5 ms
    ^Z
    [8]+  Stopped                 ping 192.168.10.154
    [root@iZuf6hgotc     :Z conf]#

IDaaS EIAM 1.0 configuration

To use an IDaaS EIAM 1.0 instance, perform the following steps. You need to enable LDAP authentication and bind the EIAM 1.0 instance when you create the SSL server. The other steps are the same as for EIAM 2.0.

Procedure

image

LDAP authentication

Before you establish an SSL-VPN connection, you must enable LDAP authentication and synchronize account data in the IDaaS EIAM 1.0 instance for subsequent identity verification.

  1. Add an LDAP authentication source.

    1. Log on to the IDaaS console.

    2. On the EIAM page, click the Legacy Version tab and find the ID of the target instance.

    3. In the left-side navigation pane, click Authentication Source.

    4. In the upper-right corner of the Authentication Source page, click Add Authentication Source.

    5. On the Add Authentication Source page, find the LDAP icon LDAP图标 and click Add Authentication Source in the Actions column.

    6. In the Add Authentication Source (LDAP) panel, configure the LDAP server (the AD server in this topic) and click Submit.

      • ID: The ID is automatically generated by the system.

      • Name: Enter a custom name.

      • LDAP URL: The connection URL of the LDAP server. The LDAP server is the server where you deployed the AD system. The URL must be in the ldap://127.0.0.1:389/ format. In this example, enter ldap://47.XX.XX.62:389/.

        If the host IP address is an IPv6 address, enclose the address in square brackets ([]). Example: ldap://[0000:0000:0000:0000:0000:0000:0001]:389/.

        Note

        IDaaS can be accessed only over the public network. The LDAP server must have a public IP address, and port 389 must be open. You can configure a security group rule for the LDAP server to allow access only from the public IP addresses of IDaaS. To obtain the public IP addresses of IDaaS, submit a ticket to the Alibaba Cloud IDaaS team.

      • LDAP Base: The Base DN of the LDAP server. In this example, enter dc=zxtest,dc=com.

      • LDAP Account: The DN of the administrator account on the LDAP server. In this example, enter cn=Administrator,cn=Users,dc=zxtest,dc=com.

      • LDAP account password: The password of the administrator account on the LDAP server.

      • Filter Condition: The filter for querying usernames. In this example, enter (sAMAccountName=$username$).

        For more information about matching rules, see the official LDAP documentation LDAP Filters. The $username$ parameter specifies the username in the IDaaS system and is a fixed value.

    7. On the Authentication Source page, find the target authentication source, click the 启用 icon in the status column, and then click Submit in the dialog box that appears to enable the LDAP authentication source.

  2. Configure LDAP account synchronization to import account data from the LDAP server to the IDaaS system.

    1. In the left-side navigation pane, click OUs and Groups.

    2. In the upper-right corner of the OUs and Groups page, click Configure LDAP. In the Configure LDAP panel, click Create.

    3. On the Server Connection tab of the Configure LDAP panel, configure the following parameters and click Save.

      • AD/LDAP Name: Enter a custom name.

      • Server Address: Enter the public IP address of your LDAP server. In this example, enter 47.XX.XX.62.

      • Port Number: Enter the service port number of your LDAP server. In this example, enter 389.

      • Base DN: Enter the DN of the node whose accounts you want to synchronize. In this example, enter dc=zxtest,dc=com.

        Note

        This parameter cannot be modified after it is configured. If you change the Base DN, the organization directory on the IDaaS system does not match the organization directory on the LDAP (or AD) server, and data synchronization fails. To synchronize data from different directories, add multiple LDAP configurations.

      • Administrator DN: Enter the DN of the administrator account. In this example, enter cn=Administrator,cn=Users,dc=zxtest,dc=com.

      • Password: Enter the password of the administrator account.

      • Select Type: Select the type of your LDAP server. In this example, select Windows AD.

      • Owned OU node: The node in the IDaaS organization structure to which the account data is imported. If you do not select a node, the data is imported to the root OU. In this example, the default value is used.

      • From LDAP to IDaaS: If you enable this feature, you can manually synchronize data from the LDAP server to the IDaaS system. In this example, select Enable.

      • Provision from IDaaS to LDAP: If you enable this feature, you can synchronize data from the IDaaS system to the LDAP server. In this example, select Enable.

      After completing the preceding configurations, you can click Test Connection to test the server connectivity. If the test fails, check the network connectivity and whether the connection parameters are correctly configured.

    4. On the Field Matching Rules tab of the Configure LDAP panel, configure the following parameters and click Save.

      A field mapping rule defines how fields in the IDaaS system map to attributes in the LDAP server. For example, the cn field in the LDAP server maps to the username in the IDaaS system.

      • UserName: In this example, enter cn.

        Note

        If the value of the cn field for an account in your AD system contains Chinese characters, the IDaaS system cannot import the account. We recommend that you use the sAMAccountName field.

      • External ID: For Windows AD, use objectGUID. For OpenLDAP, use uid. In this example, enter objectGUID.

      • Password Attribute: For Windows AD, use unicodePwd. For OpenLDAP, use userPassword. In this example, enter unicodePwd.

      • User Unique Identifier: For Windows AD, use DistinguishedName. For OpenLDAP, use EntryDN. In this example, enter DistinguishedName.

      • Email: In this example, enter mail.

    5. On the OUs and Groups page, choose Import > Organization Structure.

    6. In the LDAP List panel, find the target LDAP, click Import, and then click Submit in the dialog box that appears. In the OU Temporary Data panel, confirm the organization information and click Submit.

    7. In the OUs section of the current page, select the target organization. In the details section of the organization, choose Import > Account.

    8. In the LDAP List panel, find the target LDAP configuration and click Import. In the dialog box that appears, click Submit. In the Account Temporary Data from LDAP panel, confirm the account information, click Submit, and then set a default password for the imported accounts to synchronize account information from the LDAP server to the IDaaS system.

      Important

      Clients must use the password from the AD server for subsequent logons. The password configured here applies only to the IDaaS instance.

  3. Enable LDAP authentication for cloud products.

    1. In the left-side navigation pane, choose Settings > Security Settings.

    2. On the Security Settings page, click the AD Authentication for Cloud Service tab.

    3. Select the LDAP authentication source that you just created, enable the feature, and click Save.