Help Center> Host Security Service (Old)> FAQs> Deployment and Configuration> Agent> How Do I Install the Agent on Servers in Batches?
Updated on 2022-09-08 GMT+08:00

How Do I Install the Agent on Servers in Batches?

This section describes how to install the agent in batches in different OSs. For details about the OSs supported by the agent, see Constraints.

Windows OS

Perform the following steps to install Windows agents in batches by using an image:

  1. Purchase a HUAWEI CLOUD ECS and select the required Windows OS image. For details, see Purchasing an ECS.
  2. Install the HSS agent on the purchased ECS. For details, see Installing an Agent on the Windows OS.

    Do not enable services or modify configurations other than those required for installing HSS agents.

  3. Stop the HostGuard process in the Windows Task Manager.
  4. Delete the files in C:\Program Files(x86)\HostGuard\config\agentinfo.
  5. Stop the ECS and use it to create an image. For details, see Creating an Image.

    After the ECS is stopped, do not restart it before creating an image. Otherwise, you need to perform Step 3 and Step 4 again.

  6. Use the created image to install agents on Windows ECSs in batches.

    The agent status will be automatically refreshed 5 to 10 minutes after the installation succeeded.

Linux OS

Install Linux agents in batches in either of the following ways:

Method 1: Installing agents in batches using scripts

Prerequisites

Prepare a Linux computer used for running the batch installation script.
  • Log in to the Linux computer and the target servers with the same user.
  • Exchange data between the Linux computer and the target servers via SSH without requiring passwords.
  • Configure the Linux computer to ignore SSH login authentication.

Procedure

  1. Download the batch installation script, as shown in Figure 1.

    Figure 1 Downloading the installation script

  2. Collect the IP addresses, SSH username and password, and passwords of the root user for logging in to the target servers.
  3. Save the IP addresses, SSH username and password, and passwords of the root user in a text file hostinfo.txt (UTF-8) in sequence and separate them with spaces. A single record occupies a line, terminated by a line feed. The file format is Unix.

    For example, there are two servers. The IP address, SSH username, and password of the root user for logging in to server A is 192.168.1.101, root, and 123456, separately. The IP address, SSH username and password, and password of the root user for logging in to server B is 192.168.1.102, test, test123, and 123456 (see Figure 2).
    Figure 2 Example

  4. Use a Linux computer (4 vCPUs, 8 GB is recommended) to run the script. This computer must be able to connect to the target servers via SSH (port 22).
  5. Check whether Ansible is installed on the Linux computer. If no, install Ansible.
  6. Upload the host configuration file hostinfo.txt and the agent installation script (deploy-ansible-expect) to the same directory on the Linux computer.
  7. Run the sh config.sh hostinfo.txt command to generate the configuration file hosts required by Ansible.
  8. Run the chmod u+x install.sh; ./install.sh command to complete the batch installation.
  1. When you execute the Ansible script, the su command is executed by default to switch to the root user. However, on some ECSs, running the su command cannot switch to the root user. If the operation fails due to insufficient permission, modify ansible_become_method=su in the hosts file in the installation script to ansible_become_method=sudo, save the file, and run the install.sh script again.
  2. The error message shown in the following figure may be displayed when Ansible is used to install HSS agents on some ECSs (the error was found on ubuntu16). That is because the default python is not configured on the target ECSs. You can use either of the following methods to remove this error:

    1. Follow the steps as instructed in How Do I Install an HSS Agent? to install an HSS agent.
    2. Log in to the required server and set the default Python.

      You can run sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10.

      Alternatively, you can run ln -s /usr/bin/python3 /usr/bin/python(ln -s /usr/bin/python2 /usr/bin/python).

  3. The agent status will be automatically refreshed 5 to 10 minutes after the installation succeeded.

Method 2: Installing agents in batches using an image

  1. Purchase a HUAWEI CLOUD ECS and select the required Linux OS image. For details, see Purchasing an ECS.
  2. Install the HSS agent on the purchased ECS. For details, see Installing an Agent on the Linux OS.

    Do not enable services or modify configurations other than those required for installing HSS agents.

  3. Stop the HSS process on the ECS.

    Run the ps -ef command to check the PID of the HSS, and then run the kill -pid command to stop the hostguard process in the Linux OS.

  4. Delete the configuration file.

    Run the rm -rf command to delete the files in the /usr/local/hostguard/conf/agentinfo directory in the Linux OS.

  5. Stop the ECS and use it to create an image. For details, see Creating an Image.

    After the ECS is stopped, do not restart the ECS before creating an image. Otherwise, you need to perform Step 3 and Step 4 again.

  6. Use the created image to install agents on Linux ECSs in batches.

    The agent status will be automatically refreshed 5 to 10 minutes after the installation succeeded.

Agent FAQs

more