Linux virtual machines must require SSH key authentication instead of username/password. Password-based login is susceptible to brute-force attacks and credential compromise, which can lead to unauthorized access and lateral movement.
For Ansible azure_rm_virtualmachine resources, ensure ssh_password_enabled is set to false and linux_config.disable_password_authentication is set to true so only SSH key authentication is allowed. This rule applies to resources intended to be Linux VMs (where os_type is "linux" or unspecified). Resources missing these properties or that allow password authentication are flagged.
Secure example configuration:
- name:Create Linux VM with SSH keys onlyazure_rm_virtualmachine:name:my-linux-vmresource_group:my-rgos_type:Linuxssh_password_enabled:falselinux_config:disable_password_authentication:truessh_public_keys:- path:/home/azureuser/.ssh/authorized_keyskey_data:"{{ lookup('file','~/.ssh/id_rsa.pub') }}"
Compliant Code Examples
---- name:Create a VM with a custom imageazure_rm_virtualmachine:resource_group:myResourceGroupname:testvm001vm_size:Standard_DS1_v2ssh_password_enabled:falsessh_public_keys:- path:~/.ssh/id_rsa.pubkey_data:somegeneratedkeydataimage:customimage001os_type:Linux
Non-Compliant Code Examples
---- name:Create a VM with a custom imageazure_rm_virtualmachine:resource_group:myResourceGroupname:testvm001vm_size:Standard_DS1_v2admin_username:adminUseradmin_password:password01image:customimage001os_type:Linux
1
2
rulesets:- Ansible / Azure # Rules to enforce / Azure.
맞춤형 데모 요청
Datadog 시작하기
Ask AI
AI-generated responses may be inaccurate. Verify important info.