HANA secure store using hdbuserstore

Trace HTTP activity to troubleshoot issues related to XS engine or Web applications.

Requirement: You want to connect to HANA system using HDB client tool hdbsql and want to use hdbuserstore for secure store creation.

Prerequisite: You need SAP HANA client installed and OS level access to maintain hdbuserstore.You also need OS level access from the client you are trying to connect.


What is SAP HANA hdbuserstore ?
HANA hdbuserstore is a tool provided by SAP to securely store the connection information of HANA system including passwords. HANA hdbuserstore is installed with the SAP HANA client.

Typically this is used when you want to connect the SAP HANA in batch mode (via scripts).

Please note: Once the hdbuserstore KEY is set , the HANA user password is not visible to us , we can only call the connection with the unique KEY and that key is mapped with an SAP HANA system and user credentials. 

How to connect to SAP HANA system using hdbuserstore from any HANA client?
Our Scenerio
In our example we are trying to connect to HANA DEV system from HANA QAS system , this is just for the explanation purpose. You can use this approach to connect to any HANA system from any client system. 

Target System : saphanadev.yourcompany.domain.com
Target Instance Number  : 00
Target HANA user : SYSTEM 
Password : In123
Source system(HANA client)  : saphanaqas


Steps:
Install SAP HANA client. You can refer this document if you are connecting from Windows. How to install HANA client on windows

Login at OS level and issue following command to create an hdbuserstore secure store unique key.

hdbuserstore SET DEV "saphanadev.yourcompany.domain.com:30015" SYSTEM In123

For MDC(Multi Database Container : Multiple tenant in one database) system, use following command

For systemDB :
    hdbuserstore SET SYS_DEV "saphanadev.yourcompany.domain.com:30013" SYSTEM In123
For Default Tenant :
    hdbuserstore SET DEV "saphanadev.yourcompany.domain.com:30015" SYSTEM In123
For Second Tenant :
    hdbuserstore SET DE2 "saphanadev.yourcompany.domain.com:30041" SYSTEM In123

You can run following SQL from SystemDB to check various HANA tenants and their SQL HANA ports

SELECT DATABASE_NAME , SERVICE_NAME, SQL_PORT 
FROM SYS_DATABASES.M_SERVICES 
WHERE SERVICE_NAME='indexserver' AND CORDINATOR_TYPE='MASTER';


In above listed query DEV is the unique key , we will use this key while making connections with hdbsql.

Now execute following command to list all the hdbuserstore secure store keys.
hdbuserstore LIST

To verify the entry , we will issue an SQL query using HDBSQL and unique key.
hdbsql -U DEV "select count(*) from "_SYS_STATISTICS"."STATISTICS_ALERTS_BASE"" ;

In case you need to delete any secure store entry then you can used following SQL.

hdbuserstore DELETE DEV

If you need to update an existing entry then issue the create query again with chnaged parameters.


Related: