Creating a Windows Agent Image
Preparing an ECS
Prepare an ECS that runs Windows Server 2019 Standard 64bit English and has a 40 GB system disk. Windows Server 2019 is used as an example, and you can select another version. Specify a valid password when creating the ECS and name the ECS SMS. The official Microsoft image is recommended.
Ensure that the ECS can access the Internet, so that the required tools can be downloaded.
Installing the Required Software
- Transfer the smsWindowesAgent folder created in Creating Scripts in Agent Images to the C:\directory of the ECS. The folder stores the agent image scripts you prepared.
- Install Python 3.7.6 to C:\smsWindowsAgent\Python. You can select another version as required.
- Run where python to check whether Python has been installed in the specified directory.
Installing requests and ConfigParser
Run the following commands on the ECS to install requests and ConfigParser.
pip install requests pip install configparser
Modifying the ECS
- Enable scripts to automatically run upon ECS startup.
- Open the cmd and run gpedit. In the displayed window, choose Computer Configuration > Windows Settings > Scripts (Startup/Shutdown) > Startup.
- Click Add and specify C:\smsWindowesAgent\bin\Name of script for running Python.bat for Script Name.
- Open the cmd and run gpedit. In the displayed window, choose Computer Configuration > Windows Settings > Scripts (Startup/Shutdown) > Startup.
- Install OpenSSH.
- Right-click the Start icon or press Win and X keys. In the displayed menu, choose Windows PowerShell (Administrator). In the displayed window, run the following command:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
- After the installation is complete, restart the OS for the installation to take effect. Start the sshd and ssh-agent services and set them to automatically run at startup.
Start-Service sshd
Enable sshd to automatically run at startup.
Set-Service sshd Automatic
Start ssh-agent.
Start-Service ssh-agent
Enable ssh-agent to automatically run at startup.
Set-Service ssh-agent -StartupType Automatic
- Go to the C:\ProgramData directory and add the following content to the sshd_config file:
PasswordAuthentication no
- Right-click the Start icon or press Win and X keys. In the displayed menu, choose Windows PowerShell (Administrator). In the displayed window, run the following command:
- Install OpenStack.
Download the VMTools drivers required by SMS.
Decompress the downloaded package, double-click the extracted file, and find the required drivers in ./vmtools-windows/upgrade/windows XX/drivers.
Copy all driver files to the specified directory.
Windows Server 2016_64bit is used here as an example.
Copy all files in upgrade\windows 2016_64\drivers\viostor to C:\smsWindowsAgent\bin\peAgent\OpenStack\windows_device_driver\windows2016_64.
Copy files in the rest of folders under upgrade\windows 2016_64\drivers to C:\smsWindowsAgent\bin\peAgent\OpenStack\windows_device_driver\windows2016_64.
The picture below shows the files copied to the C:\smsWindowsAgent\bin\peAgent\OpenStack\windows_device_driver\windows2016_64 directory.
Copy files required by other Windows versions to the corresponding directories.
- Open ports 8899 and 8900 on the ECS.
netsh advfirewall firewall add rule name=peagent dir=in action=allow protocol=TCP localport=8899 netsh advfirewall firewall add rule name=ntcldst dir=in action=allow protocol=TCP localport=8900
- (Optional) Install the password reset plug-in if you did no use a public image to create this ECS.
- Download the plug-in at https://cn-south-1-cloud-reset-pwd.obs.cn-south-1.myhuaweicloud.com/windows/reset_pwd_agent/CloudResetPwdAgent.zip.
- Double-click setup.bat in the CloudResetPwdAgent.Windows or CloudResetPwdUpdateAgent.Windows directory.
- In the Task Manager, search for cloudResetPwdAgent and cloudResetPwdUpdateAgent.
- If they are there, the installation is successful.
- If they are not there, the installation fails.
(Optional) Hardening Security
- Disable remote login.
Open the Control Panel, choose System and Security > System > Allow remote access, and select Don't allow remote connections to this computer.
- Disable the WinRM service.
- Set a password login policy to block brute-force attacks.
- Open the cmd or PowerShell as an administrator.
- Run the gpedit.msc command to start Local Group Policy Editor.
- In the displayed window, choose Computer Configuration > Windows settings > Security Settings > Account Policy > Account Lockout Policy. Set the account locking policy shown in the following figure. This policy indicates that if there are 6 consecutive unsuccessful login attempts, the account will be blocked for 3 minutes.
- Close listening ports in the Windows firewall.
- Open the cmd and run the netstat -ano command to check all listening ports.
- Close all dynamic ports (49152-65535) and port 135 used for listening.
netsh advfirewall firewall add rule name=Tcp_disable dir=in action=block protocol=TCP localport=135,3389,5985,5986,49152-65535
- Close all UDP ports.
netsh advfirewall firewall add rule name=Tcp_disable dir=in action=block protocol=UDP localport=any
- Open the cmd and run the netstat -ano command to check all listening ports.
Creating an Image
- Log in the IMS console.
- Click Create Image.
- Create a system disk image for the ECS as prompted.
- View the ID of the created image.
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