All Products
Search
Document Center

Bastionhost:Best practices of database O&M

Last Updated:Mar 31, 2026

Bastionhost Enterprise Edition and SM Edition let O&M engineers securely connect to database assets through an SSH tunnel or browser, with every session automatically recorded for audit.

Supported databases include ApsaraDB RDS for MySQL, ApsaraDB RDS for SQL Server, and ApsaraDB RDS for PostgreSQL; PolarDB for MySQL, PolarDB for PostgreSQL, and PolarDB for PostgreSQL (Compatible with Oracle); and self-managed MySQL, SQL Server, PostgreSQL, and Oracle databases.

Bastionhost Enterprise and SM Edition are built on a reliable dual-engine architecture. Both engines are active, which ensures business continuity and meets the high requirements of database O&M. For more information, see Comparison of features between Bastionhost editions.

How it works

All database connections go through Bastionhost as a proxy. The engineer authenticates to Bastionhost with an O&M token, and Bastionhost forwards the connection to the target database. This means:

  • The database endpoint is never exposed directly to the engineer's machine.

  • All operations are recorded under the engineer's Bastionhost identity, regardless of which database account is used.

  • Administrators control which databases and accounts each engineer can reach.

Three connection methods are available:

MethodHow you connectBest for
Client-based O&MSSH tunnel from a local tool (e.g., Navicat Premium) or command lineEngineers who prefer a local GUI or CLI client
Web-based O&MBrowser session via the O&M portalQuick access without client setup
SSO O&MSingle sign-on (SSO) launcher calls a local client automaticallyTeams that want one-click access without manual SSH configuration

Prerequisites

Before you begin, ensure that you have:

The examples in this topic use a MySQL database with local users.

Client-based O&M

This method establishes an SSH tunnel from a local database tool to Bastionhost. The following examples use Navicat Premium on Windows and a command-line terminal on Linux.

For a full list of supported client tools and versions, see Recommended client connection tools and versions.

Step 1: Get the O&M address and token

  1. Log on to the O&M portal. See Log on to the O&M portal.

  2. In the left navigation pane, click Databases.

  3. Find the target database. In the Remote Connection column, select View O&M Token from the Login Method drop-down list, then click Log On.

  4. In the O&M Token dialog box, click Apply For O&M Token.

    If the current database account is not hosted on Bastionhost, you must first configure the basic information of the database account in the O&M Token dialog box before applying for a token. See Database management.

The dialog box shows the Client SSH Tunnel Configuration section with the values you need for the next step.

Step 2: Establish the SSH tunnel

Navicat Premium

  1. Open Navicat Premium and create a MySQL connection.

  2. On the SSH tab, select SSH Tunnel and fill in the SSH tunnel parameters:

    ParameterValue
    HostThe public or private O&M address from the Client SSH Tunnel Configuration section
    PortThe SSH tunnel O&M port. Default: 60022
    User NameYour Bastionhost username
    PasswordThe O&M token from Step 1

    image

  3. On the General tab, fill in the database connection details:

    Save the password in Navicat. If you leave it blank, Navicat may prompt for a password during connection — enter the O&M token in that case.
    ParameterValue
    HostThe database endpoint
    User NameThe database account username
    PasswordLeave blank if the administrator has hosted the account credentials in Bastionhost. Otherwise, enter the database password.

    image

  4. Double-click the connection to connect. You can now run O&M operations on the database.

Terminal (command line)

  1. Run the following command to open the SSH tunnel:

    PlaceholderDescription
    <localport>A local port you choose for the tunnel. Make sure it is not already in use.
    <databaseAddress>The endpoint of the target database
    <databasePort>The port of the target database
    <bastionusername>Your Bastionhost username
    <bastionAddress>The public O&M address of Bastionhost
    <bastionPort>The SSH O&M port. Default: 60022
    ssh -N -L <localport>:<databaseAddress>:<databasePort> <bastionusername>@<bastionAddress> -p <bastionPort>

    Example:

    ssh -N -L 33061:rm-******m020h.mysql.rds.aliyuncs.com:3306 bastuser@******-public.bastionhost.aliyuncs.com -p 60022
  2. When prompted for a password, enter the O&M token and press Enter. The terminal waits — this is expected.

    image

  3. Open a second terminal and verify that the local port is listening. The output should show LISTEN next to your chosen port.

    image

  4. Connect to the database through the tunnel:

    PlaceholderDescription
    <accountname>The database account username
    <localport>The local port you specified in step 1
    mysql -h 127.0.0.1 -u <accountname> -P <localport>

    You can now run O&M operations on the database.

    image

Web-based O&M

Connect directly from a browser — no SSH tunnel or client configuration required. You can use the O&M portal or web console for web-based O&M. The following steps use the O&M portal as an example.

  1. Log on to the O&M portal of Bastionhost. See Log on to the O&M portal.

  2. In the left navigation pane, click Databases.

  3. Find the target database. In the Remote Connection column, select Web Remote Connection from the drop-down list, then click Log On. A browser-based database session opens.

    image

SSO O&M

The SSO (single sign-on) launcher detects your local client and opens a session automatically — no manual SSH configuration needed. This example uses DBeaver 23 on Windows.

For supported client tools, see Clients supported by the single sign-on launcher.

Step 1: Get the O&M portal address

  1. Log on to the Bastionhost console. In the top navigation bar, select the region where your Bastionhost instance is located.

  2. In the instance list, find your instance and click Manage.

  3. In the left navigation pane, click Overview to see the O&M portal address.

    image

Step 2: Install the single sign-on launcher

  1. Enter the O&M portal address in your browser.

  2. On the Alibaba Cloud Bastionhost login page, enter your username and password, then click Log On.

  3. Click Download Single Sign-on Launcher and download the Windows installer.

    image

  4. Install the launcher. You do not need to open it after installation.

Step 3: Configure the O&M terminal

  1. In the left navigation pane of the O&M portal, click Device Settings.

  2. On the MySQL tab, select DBeaver and click Save.

    image

  3. In the usmsso.exe dialog box, click Open and follow the on-screen instructions to finish configuring the client.

Step 4: Connect to the database

  1. In the left navigation pane, click Databases.

  2. Find the target database. In the Remote Connection column, select Local Client Logon from the drop-down list, then click Log On. DBeaver opens and connects to the database automatically.

    image

Audit sessions

After an O&M session ends, Bastionhost generates session records and operation logs. Auditors can review these records or monitor active sessions in real time to detect unauthorized operations.

  1. Log on to the Bastionhost console and select the region of your instance.

  2. In the instance list, find your instance and click Manage.

  3. In the left navigation pane, choose O&M Audit > Session Audit.

  4. On the Session Audit page, view or search session records.

Audit logs record the user who requested the O&M token, not the username or asset account entered in the client tool.

Troubleshooting

Token-related issues

SymptomCauseAction
Connection fails even though the token is validConcurrent O&M connection limit reachedContact your administrator to upgrade the Bastionhost instance type or release idle connections
Connection fails even though the token is validSource IP address or time period blocked by administratorContact your administrator to remove the restrictions
Token expired before useToken validity period elapsedRequest a new token. If O&M approval is enabled, submit a new approval request.
New token settings not taking effectSettings were changed after the token was issuedRequest a new token or update the existing one

Token renewal

  • If the administrator allows self-renewal, renew the token before it expires.

  • After a token expires, request a new one.

  • If O&M approval is enabled, token self-renewal is not available.

What's next