Updated on 2026-01-13 GMT+08:00

Creating Scripts in Agent Images

Precautions

  • You need to prepare scripts based on the OS of the servers to be migrated.
  • You need to prepare required scripts on your own. If you need help, contact the technical support.
  • The methods of creating Windows and Linux agent images are based on the script examples provided by the migration team. The script examples are only for reference.
  • You can download test scripts from the Huawei Support website for reference.

Windows

  1. Create the C:\smsWindowesAgent folder, and create the bin, Python, and smsAgent sub-folders in this folder.

    Name

    Function

    Location

    bin

    Stores the automatic startup scripts and the peagent folder.

    C:\smsWiondowesAgent\bin

    python

    The Python installation directory

    C:\smsWiondowesAgent\python

    smsAgent

    Stores Python scripts for obtaining metadata.

    C:\smsWiondowesAgent\smsAgent

    peagent

    Stores the migration components transferred from source servers to target servers.

    C:\smsWiondowesAgent\bin\peagent

  2. In the smsAgent folder, store the scripts used for obtaining certificates and keys.

    The SMS-Agent uploads SSH public and private keys to metadata of target servers. The scripts you prepared here will be used to obtain the keys from the metadata. The table below shows the three types of metadata.

    Name

    Function

    Destination File

    sms_rsa_part (to be deprecated)

    SSH public keys (for server and identity authentication)

    C:\Users\Administrator\.ssh\authorized_keys and C:\ProgramData\ssh\ssh_host_rsa_key.pub

    sms_rsa_pri_part (to be deprecated)

    SSH private keys (for server and identity authentication)

    C:\ProgramData\ssh\ssh_host_rsa_key

    sms_rsa_host_old

    New SSH public keys (for server authentication)

    C:\ProgramData\ssh\ssh_host_rsa_key.pub

    sms_rsa_host_old_pri

    New SSH private keys (for server authentication)

    C:\ProgramData\ssh\ssh_host_rsa_key

    sms_rsa_identity

    SSH public key certificates (for identity authentication)

    C:\Users\Administrator.ssh\authorized_keys

    cert_part (to be deprecated)

    Public keys for TLS 1.2 authentication

    C:\smsWindowesAgent\bin\peAgent\config\cert.pem

    prikey_part (to be deprecated)

    Private keys for TLS 1.2 authentication

    C:\smsWindowesAgent\bin\peAgent\config\prikey.pem

    sms_rsa_part and sms_rsa_pri_part are SSH public keys and private keys required for communications. The public and private keys are obtained from the metadata of target servers and then written to the destination files listed in the table above.

  3. In the bin directory, add a script to check whether peagent.exe is running.

    'tasklist /nh /fi "imagename eq peAgent.exe'

    • If it is not running, add the following command to start it.

      start cmd /k "C:\smsWindowesAgent\bin\peAgent\peAgent.exe"

    • If it is running, end the script.

    This script should be executed after the scripts in the smsAgent folder are executed.

Linux

  1. Create the ~\smsMetadataAgent directory, and create the bin, Python, and smsAgent folders in it.

    Name

    Function

    Location

    bin

    Stores the automatic startup scripts and the peagent folder.

    ~\smsMetadataAgent\bin

    smsAgent

    Stores Python scripts for obtaining metadata.

    ~\smsMetadataAgent\smsAgent

  2. Prepare scripts for obtaining public and private keys from metadata by referring to the Windows section.

    Name

    Function

    Destination File

    sms_rsa_part (to be deprecated)

    SSH public keys (for server and identity authentication)

    root/.ssh/authorized_keys and /etc/ssh/ssh_host_rsa_key.pub

    sms_rsa_pri_part (to be deprecated)

    SSH private keys (for server and identity authentication)

    /etc/ssh/ssh_host_rsa_key

    sms_rsa_host_old

    New SSH public keys (for server authentication)

    /etc/ssh/ssh_host_rsa_key.pub

    sms_rsa_host_old_pri

    New SSH private keys (for server authentication)

    /etc/ssh/ssh_host_rsa_key

    sms_rsa_identity

    SSH public key certificates (for identity authentication)

    /root/.ssh/authorized_keys

    cert_part (to be deprecated)

    Public keys for TLS 1.2 authentication

    /home/config/cert.pem

    prikey_part (to be deprecated)

    Private keys for TLS 1.2 authentication

    /home/config/prikey.pem

    Prepare automatic startup scripts by referring to the Windows section.