GuardAPI Automation - Tech
GuardAPI Automation - Tech
GuardAPI Automation
InfoSphere Guardium Technical Document
Contents
1.OVERVIEW..........................................................................................................3
2.GRDAPI ENTITLEMENTS..................................................................................3
4.1INSTALLING SSHPASS.................................................................................10
2
1. Overview
This techdoc explains a scripting method that allows the user to quickly automate
and schedule the execution of GuardAPI commands from remote server.
Smaller implementations of Guardium can be accomplished easly through the GUI, but
for large installations, a scripting method can save quite a bit of time eg. changing or
installing inspection-engines for 100 servers. If we can not run some tasks at the present
moment, we can easily also schedule script to run on the collector using auxiliary tools
for ssh. Let's imagine the situation in your company that we have centralized scheduling
server, which is a cron service on the linux box. Then if we would like to issue GuardAPI
commands we have to use ssh tool to log in as CLI user or other account to the
collector remotely. As we know SSH can not be used itself in non-interactive mode
without providing password manually to log in. For this purpose we need auxiliary
programs, which can capture interaction with ssh inserting parameter(s) like password to
automate connection process and fire a script. No other methods at this time like
exchange of the generated encryption keys or collector's internal cron can be applied to
issue self-prepared GuardAPI commands in scheduled time and with some frequence.
2. Grdapi entitlements
This section provides knowledge how to set and tailor entitlements before using
grdapi in guardium administration. Guardium is designed for automation administration
tasks from command line interface, which in some situations is definitely faster than
using GUI and Grdapi commands can be executed only through the CLI (Command
Line Interface). Most of those commands are associated with a specific application and
therefore with the roles. Having the standard CLI user (who has a hard coded 'admin'
role and is used as default) we cannot run many of the grdapi commands because it
doesn't have the appropriate roles. Of course we can grant other functions
(applications) to admin role, it is doable, but this is not best practice in the companies,
especially in the corporations. Besides CLI user, guardium is shipped with five additional
CLI accounts (guardcli1, guardcli2, guardcli2, guardcli4, guardcli5) for separate
administration duties as we decide to use them.
If we log in first time to the collector for one of the mentioned users, the default password
for each is 'guardium' and first logging forces us to change it.
3
CLI account always is associated with guardium GUI user, who has appropriate access
to the functions and applications of the guardium. As was mentioned CLI is assigned
'admin' role in the code of the system, but other guardcli1,...,guardcli5 users must first
set gui user before issuing any grdapi commands.
set guiuser <gui_user> password <password>
if we don't do that after logging we will not able to issue any commands and we get
following message:
For our purpose access manager (accessmgr) can define as many users in the system
and give them the CLI role. These users will have access to the CLI and all activities of
their CLI sessions are associated with this user.
If the gui user attempting to use CLI has a "CLI" role, CLI will start and we
can use grdapi commands according to assigned entitlements.
4
Let's see how it works switching gui users and what gradpi commands are accessible for
each of these users with different roles. We will be changing between 3 users (roles):
robert (cli), admin (admin) and accessmgr (accessmgr). Each of them will issue the
same command to compare access to guardium API functions:
Admin role:
5
Accessmgr role:
According to the above print screens, accessmgr role is responsible for management of
users and gets access to bunch of these grdapi commands to manage them and their
entitlements. Those commands can be run only by users with this role. For instance of
Admin and CLI roles, they don't have such capability and can be used for other
operations and administration taks.
Finally let's check what other possibilities using grdapi has got CLI role if we know it
cannot be used to manage users, bc we already know it's a feature of guardium to
separate duties. To do that we can issue simply:
grdapi commands
6
]
7
3. Grdapi automation use cases
Grdapi is a great functionality which saves a lot of time in deploying changes for large
installation. Let's imagine that for some reason company is forced to change network
settings, update inspection-engines or turn on different debug levels for troubleshooting.
Are we going to do that manually from GUI let's say for 100 servers ? The answer
comes immediately, NO! For that purpose we can use grdapi scripting and automate
certain tasks.
Value-added: We don't have to change a debug level for a short time for each agent
through the GUI manually, because we would like to troubleshoot some activity For
large installation it is even impossible to reach this situation and not exaggerating it
could take even few days , that way we can loose objective of our research. This is
possible only with a scripting method which can save our precious time and to help
getting the goal.
8
grdapi create_stap_inspection_engine stapHost=10.10.9.28 protocol=Oracle
portMin=1521 portMax=1521 dbInstallDir=/home/oracle/product/10.2.0/ora10
grdapi create_stap_inspection_engine stapHost=10.10.9.29 protocol=Oracle
portMin=1521 portMax=1521 dbInstallDir=/home/oracle/product/10.2.0/ora10
grdapi create_stap_inspection_engine stapHost=10.10.9.28 protocol=DB2
portMin=1521 portMax=1521 dbInstallDir=/home/oracle/product/10.2.0/ora10
grdapi delete_stap_inspection_engine stapHost=192.168.2.118 type=Oracle
sequence=1
Value-added: Changing configuration for large installation is definitely easier and faster.
To accomplish this small lab we will use following credentials for our virtual machines:
9
Login for dataserver:
user: guard
password: password
1. Let's install SSHPASS first which we will use later for login automation to the
collector or aggregator.
Open console Gnome Terminal double clicking on icon on the Desktop or other
localization
cd ~guard/Scripts/
tar zxvf sshpass-1.04.tar.gz
10
Next, we'd like to compile and install our package. To do that change your folder to
sshpass-1.04/ and issue following commands
cd sshpass-1.04/
./configure
make
sudo make install
2. Let's now prepare our script Grdapi_commands.txt which will be used as a set
of grdapi commands and an input for scheduler. In our case we are going to restart
STAP on the selected host.
cd ~guard/Scripts/
11
Follow with the instructions:
cd ~guard/Scripts/
vi Grdapi_autologin.txt
press [ESCAPE] and “i”, rewrite or copy/paste the 2 lines below
#!/bin/sh
/usr/local/bin/sshpass -p 'guardium' ssh [email protected] <
/home/guard/Scripts/Grdapi_commands.txt
Note that provided password guardium for sshpass program will be passed to ssh after
establishing the connection.
To make sure that this command is correct let's run our script once from the console
If this is a first logging attempt it would be good to log manually using sshto the collector
to let generate ssh a RSA key and add host to the known hosts.
Finally fire ./Grdapi_autologin.txt script to check you receive the same result as above
12
As we can see command is invoked properly and we didn't have to provide password
also, it was done without interaction once again.
4. Now we are going to configure cron to run the script each 30 minutes on the
collector
*/30 * * * * /home/guard/Scripts/Grdapi_autologin.txt
To add this line we have to do few steps, first open crontab file:
crontab -e
You should see following view. Note, there can be more existing entries, in our example
we have only one.
13
Congratulations ! Our GuardAPI command will be issued each 30 minutes on the
collector.
This is of course simple scenario how you may use GuardAPI commands which we
can to use in scheduled time. We can add more commands to our script
Grdapi_commands.txt for other purpose simplifying administration.
14
© Copyright IBM Corporation 2011
All Rights Reserved.
IBM Canada
8200 Warden Avenue
Markham, ON
L6G 1C7
Canada
15