Require MFA for accessing cloud resources
This topic describes how to use RAM to require multi-factor authentication (MFA) when RAM users access cloud resources, such as ECS.
Prerequisites
Before you create a custom policy, make sure you understand the basic elements and syntax of the permission policy language. For more information, see Permission policy elements and Policy structure and syntax.
Download and install the Alibaba Cloud App on your mobile device. Download the app as follows:
For iOS: Search for Alibaba Cloud in the App Store.
For Android: Search for Alibaba Cloud in your preferred app store.
Step 1: Create a custom policy
Log on to the RAM console as a RAM administrator.
In the left-side navigation pane, choose .
On the Policies page, click Create Policy.
On the Create Policy page, click the JSON Editor tab.
The page displays a JSON editor. The default policy template includes a
Versionelement (set to"1") and aStatementarray. Each statement includesEffect(defaults to"Allow"),Action,Resource, andConditionelements. You must populate theActionandResourceelements.Enter the policy document.
Example policy: Only RAM users with MFA enabled can access ECS resources in the console. You can implement this by using the
Conditionelement to set the value ofacs:MFAPresenttotrue.{ "Statement": [ { "Action": "ecs:*", "Effect": "Allow", "Resource": "*", "Condition": { "Bool": { "acs:MFAPresent": "true" } } } ], "Version": "1" }NoteThe
Conditionelement applies only to the actions specified in this permission policy. You can modify the policy document to restrict access to other cloud resources as needed.At the top of the page, click Optimize, and then click Perform to perform advanced optimization on the policy.
The advanced policy optimization feature performs the following tasks:
Splits resources or conditions for incompatible actions.
Narrows the scope of resources.
Removes duplicate statements or merges statements.
On the Create Policy page, click OK.
In the Create Policy dialog box, enter a policy name and Description, and then click OK.
Step 2: Create a RAM user
Sign in to the RAM console using your Alibaba Cloud account or as a RAM user with administrative permissions (a user to which the
AliyunRAMFullAccesspolicy is attached).In the left-side navigation pane, choose .
On the Users page, click Create User.
On the Create User page, in the User Account Information section, configure the user's basic information.
Logon Name (required): Up to 64 characters. Allows letters, digits, periods (.), hyphens (-), and underscores (_).
Display Name (optional): The name can be up to 128 characters long.
Tag (optional): Click
, then enter a tag key and tag value to categorize and manage users.Security Phone (optional): Enter a mainland China mobile number in +86 format. +86 is the country/region code and is selected by default; enter only the phone number itself. After the first binding, the number must be activated through SMS verification.
NoteClick Add User to create multiple RAM users in bulk.
In the Access Mode section, select an access mode based on the user type.
ImportantAs a security best practice, select only one access mode per user to separate human console access from programmatic application access. If a RAM user needs both console sign-in and API call capabilities, you can select both access modes. After you select Permanent AccessKey, you must select the I confirm that I must create an AccessKey checkbox to continue.
A leaked AccessKey pair compromises your account. Use Security Token Service (STS) tokens (temporary credentials) instead to reduce risk. Best practices for using access credentials to call Alibaba Cloud APIs.
Console access
Select Console Access.
Set Logon Password: Auto-generate or set a custom password. Custom passwords must meet the configured complexity requirements. Set a password policy for RAM users.
Password Reset: Specify whether the user must reset the password at next sign-in.
Enable MFA: MFA is required for all users by default. To change this setting, see Manage RAM user security settings. Users must bind an MFA device at first sign-in. Bind an MFA device.
Programmatic access
Select Permanent AccessKey.
The system automatically creates an AccessKey ID and AccessKey secret for the RAM user.
ImportantThe AccessKey secret is displayed only at creation and cannot be retrieved later. You must immediately download or copy and save the AccessKey secret. A leaked AccessKey pair compromises all resources under your account. Create an AccessKey pair.
Step 3: Grant permissions
Grant the custom policy that you created in Step 1 to the RAM user that you created in Step 2.
-
Log on to the RAM console.
-
In the left-side navigation pane, choose .
-
On the Users page, find the target RAM user and click Actions column > Attach Policy.
You can also select multiple RAM users and click Attach Policy below the user list for batch authorization.
-
In the Grant Permission panel, configure the following settings:
-
Resource scope:
-
Account level: Permissions apply to all resources in your Alibaba Cloud account.
-
Resource group level: Permissions apply only within the specified resource group. After logging on, the RAM user must switch to the authorized resource group in the top navigation bar.
Note-
The system marks high-risk system policies (such as AdministratorAccess and AliyunRAMFullAccess) with a warning indicator. These policies typically grant full control over all cloud resources or full management of RAM. Grant these policies with caution.
-
For resource group authorization examples, see Control RAM user access to specific ECS instances.
-
-
-
Principal:
The principal is the RAM user receiving permissions. From the Users page, the system auto-selects the current user. From the Grants page, you must manually select the user. Batch selection is supported.
-
Permission policy:
-
System policy: Search and select. Filter by product name (e.g.,
ECS,OSS), access level (e.g.,ReadOnly,FullAccess), or full policy name. For example, to grant permissions for financial management (expenses and costs), search forBSSto findAliyunBSSFullAccess(full access to Billing and Cost Management) and other finance-related policies.The following table lists system policy names for commonly requested Alibaba Cloud products to help you quickly find the right policy.
Product
System policy name
Access level
Billing and cost management (finance)
AliyunBSSFullAccessFull access
Cloud Monitor
AliyunCloudMonitorReadOnlyAccessRead-only
China Gateway (Website Builder)
AliyunWebsiteBuildFullAccessFull access
Alibaba Cloud DevOps
AliyunYunxiaoFullAccessFull access
Model Studio (Bailian)
AliyunBailianFullAccessFull access
Alibaba Cloud DNS
AliyunDNSFullAccessFull access
SSL Certificates Service
AliyunYundunCertFullAccessFull access
Cloud Phone
AliyunECDFullAccessFull access
Support Center
AliyunSupportFullAccessFull access
Resource Center
AliyunResourceCenterFullAccessFull access
AgentBay
AliyunAgentBayFullAccessFull access
Security Center
AliyunYundunSASFullAccessFull access
If you cannot find the policy for your target product, see the System policy reference for the complete list, or create a custom policy for fine-grained access control.
-
Custom policy: You must Create a custom policy before you can grant it.
-
Pagination limit for select all: The policy list is paginated. Selecting all applies only to the current page. After you switch pages, previously selected policies remain in the selected list, but policies on the new page are not automatically selected; you must select them page by page.
-
Quickly grant administrator permissions: To grant administrator permissions, search for
AdministratorAccessin the search box and select it directly, instead of selecting policies page by page. Selecting this policy triggers a high-risk authorization warning.
-
-
(Optional) Description: Enter the authorization reason or scenario for audit purposes.
-
Click Confirm.
-
-
Review the authorization result and click Close.
Step 4: Enable MFA
Enable MFA for the RAM user you created in Step 2. For more information, see Bind an MFA device for a RAM user.