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 Huawei Cloud migration team.
- The script examples below are only for reference.
- You can download test scripts from the Huawei Support website for reference.
Windows
- In the C:\ directory, create a folder and name it smsWindowesAgent. In this folder, create three folders and name them bin, Python, and smsAgent respectively.
Folder
Function
Location
bin
Stores the startup scripts and the peagent folder.
C:\smsWiondowesAgent\bin
python
Installs Python.
C:\smsWiondowesAgent\python
smsAgent
Stores Python scripts for obtaining metadata.
C:\smsWiondowesAgent\smsAgent
peagent
Stores migration components transferred from source servers.
C:\smsWiondowesAgent\bin\peagnet
- In the smsAgent folder, store the scripts used for obtaining certificates and keys.
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.
Script
Function
Destination File
sms_rsa_part (to be deprecated)
Obtains SSH public keys (for server and identity authentication).
C:\Users\Administrator\.ssh\authorized_keys,C:\ProgramData\ssh\ssh_host_rsa_key.pub
sms_rsa_pri_part (to be deprecated)
Obtains SSH private keys (for server and identity authentication).
C:\ProgramData\ssh\ssh_host_rsa_key
sms_rsa_host_old
Obtains new SSH public keys (for server authentication).
C:\ProgramData\ssh\ssh_host_rsa_key.pub
sms_rsa_host_old_pri
Obtains new SSH private keys (for server authentication).
C:\ProgramData\ssh\ssh_host_rsa_key
sms_rsa_identity
Obtains SSH public key certificates (for identity authentication).
C:\Users\Administrator.ssh\authorized_keys
cert_part (to be deprecated)
Obtains TSL 1.2 authentication public keys.
C:\smsWindowesAgent\bin\peAgent\config\cert.pem
prikey_part (to be deprecated)
Obtains TSL 1.2 authentication private keys.
C:\smsWindowesAgent\bin\peAgent\config\prikey.pem
sms_rsa_part and sms_rsa_pri_part obtain the SSH public keys and private keys from metadata and write them to the destination files listed in the table above.
- 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.
- If it is running, end the script.
This script should be executed after the scripts in the smsAgent folder are executed.
Linux
- In the ~ directory, create a folder and name it smsMetadataAgent. In this folder, create three folders and name them bin, Python, and smsAgent respectively.
Folder
Function
Location
bin
Stores the startup scripts and the peagent folder.
~\smsMetadataAgent\bin
smsAgent
Stores Python scripts for obtaining metadata.
~\smsMetadataAgent\smsAgent
- Prepare scripts for obtaining public and private keys from metadata by referring to the Windows section.
Script
Function
Destination File
sms_rsa_part (to be deprecated)
Obtains SSH public keys (for server and identity authentication).
root/.ssh/authorized_keys, /etc/ssh/ssh_host_rsa_key.pub
sms_rsa_pri_part (to be deprecated)
Obtains SSH private keys (for server and identity authentication).
/etc/ssh/ssh_host_rsa_key
sms_rsa_host_old
Obtains new SSH public keys (for server authentication).
/etc/ssh/ssh_host_rsa_key.pub
sms_rsa_host_old_pri
Obtains new SSH private keys (for server authentication).
/etc/ssh/ssh_host_rsa_key
sms_rsa_identity
Obtains SSH public key certificates (for identity authentication).
/root/.ssh/authorized_keys
cert_part (to be deprecated)
Obtains TSL 1.2 authentication public keys.
/home/config/cert.pem
prikey_part (to be deprecated)
Obtains TSL 1.2 authentication private keys.
/home/config/prikey.pem
Prepare startup scripts by referring to the Windows section.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot