Configure a control policy

Updated at:

Bastionhost supports control policies. You can configure command, protocol control, access control, and logon control policies to manage O&M operations, which effectively prevents users from running high-risk commands or performing operations by mistake and safeguards O&M security.

Step 1: Create a control policy

  1. Log on to the Bastionhost console. In the top menu bar, select the region where the Bastionhost instance resides.

  2. In the list of Bastionhost instances, find the target instance and click Manage.

  3. In the left-side navigation pane, click Control Policies.

  4. On the Control Policies page, click Create Control Policy.

  5. On the Create Control Policy page, configure the following settings and then click Create Control Policy in the lower-right corner of the page.

    Priority

    • Valid values: 1 to 100. Default value: 1, which indicates the highest priority.

    • You can specify the same priority for different control policies. When multiple control policies have the same priority, the most recently created policy has the highest priority. Within a single policy, if the same command is specified in both the command control list and the command approval list, the priority in descending order is: reject > allow > approve.

    Command policy

    Host Command Policy

    Note

    Applies only to Linux hosts.

    Commands That Require Control

    Configure the commands that are allowed or blocked for the users and hosts to which the current policy applies.

    • (Blacklist) Listed Commands Are Not Allowed: If you select blacklist, the command control list can be empty. The commands in the blacklist command list cannot be run by the users or on the hosts to which the current policy applies.

    • (Whitelist) Only Listed Commands Are Allowed: If you select whitelist, the command control list is required. Only the commands in the whitelist command list can be run by the users and on the hosts to which the current policy applies.

    For the recommended templates of host command control policies, see Recommended templates for host command policies.

    Commands That Require Approval

    If a user runs a command that requires approval, an administrator must approve or reject the command in the Bastionhost console. The command is run after it is approved and does not take effect after it is rejected. For more information about command approval, see Command Approval.

    Note

    Command control takes precedence over command approval.

    Database Command Policy

    Commands That Require Control

    • (Blacklist) Listed Commands Are Not Allowed: If you select blacklist, the command control list can be empty. The commands in the blacklist command list cannot be run by the users or on the databases to which the current policy applies.

    • (Whitelist) Only Listed Commands Are Allowed: If you select whitelist, the command list is required. Only the commands in the whitelist command list can be run by the users and on the databases to which the current policy applies.

    • Match Mode: SQL parsing and regular expression matching are supported.

    Commands That Require Approval

    • If a user runs a command that requires approval, the command is not run. An administrator must approve or reject the command in the Bastionhost console. After the command is approved, it runs the next time that the user triggers it in the same O&M session. After the command is rejected, it is blocked the next time that the user triggers it in the same O&M session. For more information about command approval, see Command Approval.

    • Match Mode: SQL parsing and regular expression matching are supported.

    Note

    Command control takes precedence over command approval.

    Recommended templates for host command policies

    The following table describes the commands that are recommended for host command control policies and the recommended policy templates.

    Command

    Description

    Recommended policy

    reboot

    Restarts the system

    Command approval

    restart

    Restarts the system

    Command approval

    shutdown

    Shuts down the system

    Command approval

    halt

    Shuts down the system

    Command approval

    poweroff

    Shuts down the system

    Command approval

    init 0

    Stops the system

    Command approval

    pkill

    Terminates processes in batches

    Command approval

    kill

    Terminates a single process

    Command approval

    rm -rf

    Recursively force deletes files and ignores prompts

    Command approval

    mount

    Mounts a file system, which poses a risk of virus replication

    Command approval

    umount

    Unmounts a file system

    Command approval

    parted

    Partitions a file system

    Command approval

    format

    Formats a disk

    Blacklist command

    dd if=/dev/zero of=/dev/hda

    Clears the disk

    Blacklist command

    :(){:|:&};:

    Fork bomb

    Blacklist command

    (mv)(|.*)(/dev/null)

    Moves a directory to /dev/null

    Blacklist command

    (wget)(|.*)(-O- \| sh)

    Downloads and immediately runs a file

    Blacklist command

    mkfs.ext3 *

    Formats a disk

    Blacklist command

    dd if=/dev/random of=/dev/*

    Writes random data to a block device

    Blacklist command

    Protocol control

    Configure the RDP Options, SSH Options, and SFTP Options of the control policy. If you select a protocol control item, the corresponding operation is allowed. If you clear it, the operation is not allowed. For example, if you select the file upload option, users are allowed to upload files.

    Protocol option

    Configuration item

    Description

    RDP Options

    Keystroke Logging

    If you select this option, the keyboard operations performed during RDP O&M sessions can be audited. You can view the audit details in the graphical and text interfaces.

    Driver/Printer Mapping

    Controls whether drives, printers, and disks can be mapped during RDP O&M sessions.

    File Download (Drive Redirection)

    Controls whether files can be downloaded by using disk mapping during RDP O&M sessions.

    File Upload (Drive Redirection)

    Controls whether files can be uploaded by using disk mapping during RDP O&M sessions.

    Download from Clipboard

    Controls whether files or text can be downloaded from the clipboard during RDP O&M sessions.

    Upload from Clipboard

    Controls whether files or text can be uploaded to the clipboard during RDP O&M sessions.

    SSH Options

    X11 Forwarding

    Controls whether X11 forwarding is allowed during SSH O&M sessions.

    Remote Command Execution

    Controls whether you can connect to a specified host in Bastionhost over SSH in command-line mode and run the corresponding commands. For more information, see Description of remote command O&M supported by Bastionhost

    SFTP Channel

    If you clear this option, connections over the SFTP protocol are not allowed.

    SSH Channel

    If you clear this option, you cannot perform database O&M or log on to asset accounts by using SSH permissions.

    Important
    • At least one of the SSH channel and the SFTP channel must be enabled. If you clear the SSH channel, you cannot log on to asset accounts by using SSH permissions. Configure this option with caution.

    • If Enable Only SFTP Permission is configured for a host account, do not disable both the SSH channel and the SFTP channel for the account in the control policy. Otherwise, you cannot use the host account to access the target server through Bastionhost.

    SSH Forward and Reverse Tunneling

    If you enable this option, you can use VSCode and Cursor to perform O&M on SSH accounts.

    To control and audit O&M operations performed by using VSCode or Qoder, we recommend that you disable this option and require O&M engineers to connect over port 62222 through the new channel. This prevents O&M engineers from bypassing the control and auditing of O&M operations. For more information, see Best practices for using VS Code to perform O&M.

    Important

    When O&M is performed over SSH forward and reverse tunnels, Bastionhost cannot control or audit the commands that are run. Enable this option with caution.

    SFTP Options

    File Upload

    Controls file uploads during SFTP O&M sessions.

    File Download

    Controls file downloads during SFTP O&M sessions.

    File Deletion

    Controls file deletion during SFTP O&M sessions.

    File Renaming

    Controls file renaming during SFTP O&M sessions.

    Folder Creation

    Controls folder creation during SFTP O&M sessions.

    Folder Deletion

    Controls folder deletion during SFTP O&M sessions.

    Access control

    Configure whether source IP addresses can access the hosts to which the current policy applies.

    • (Whitelist) Only Listed IP Addresses Are Allowed: If you select whitelist, the IP address list is required. Only the source IP addresses in the whitelist can access the hosts to which the current policy applies.

    • (Blacklist) Listed IP Addresses Are Not Allowed: If you select blacklist, the IP address list can be empty. The source IP addresses in the blacklist cannot access the hosts to which the current policy applies.

    Logon control

    • O&M Approval: If you enable this option, O&M engineers can perform O&M on an asset only after an administrator approves their logon to the asset. For more information about O&M approval, see Review an O&M application.

    • Logon Remarks: If you enable logon remarks, O&M engineers must enter remarks before they perform web page-based O&M or single sign-on (SSO) O&M, or apply for O&M tokens.

      In the host list of the O&M portal, click the account in the remote connection column of the target host, such as [SSH] bytest. In the Remote Connection dialog box that appears, enter remarks in the required Logon Remarks field and then click OK.

Step 2: Associate assets and users

On the Assets and Users to Which Policy Is Attached page, you must associate the policy with both assets and users so that the policy takes effect on the corresponding assets and users.

  1. Associate the policy with assets. You can select Takes Effect on All Assets or Takes Effect on Selected All Assets.

    • If you select Takes Effect on All Assets, the policy takes effect on all asset accounts by default.

    • If you select Takes Effect on Selected All Assets, after you associate assets, you can associate all accounts or specified accounts.

    Note

    If you want to use a control policy to associate assets or asset accounts in batches, you can add the assets to an asset group first and then associate them in batches.

  2. Associate the policy with users. You can select Apply to All Users or Apply to Selected Users.