다음 단계에서는 Azure Policy를 사용하여 테스트 Linux VM에 SSH Posture Control 설정을 배포합니다.
배경 및 개념 참조는 SSH 자세 제어란?을 참조하세요..
고급 연습은 SSH Posture Control을 사용하여 sshd 설정 관리를 참조하세요.
Azure 계정이 없는 경우 평가판만들 있습니다.
주의
- 이 빠른 시작에서는 새 삭제 가능한 테스트 머신을 위한 제한적인 sshd 구성을 적용하는 방법을 보여 줍니다. 이 구성을 다른 컴퓨터에 적용하려는 경우 잠글 수 있습니다. SSH Posture Control과 같은 보안 제어를 시도할 때 정책 할당의 실수가 의도하지 않은 컴퓨터를 다시 구성하지 않도록 격리된 샌드박스 환경을 사용합니다.
필수 구성 요소
이 문서의 단계를 시도하기 전에 다음이 이미 있는지 확인합니다.
- 리소스 그룹, 정책 할당 및 가상 머신을 만들 수 있는 권한이 있는 Azure 계정입니다.
- 다음과 같이 Azure와 상호 작용하기 위한 기본 설정 환경:
- Azure Cloud Shell (권장)
- 참고: 예제에서는 bash 모드를 사용합니다. 판독기는 PowerShell을 비롯한 다른 셸 환경에 예제를 적용할 수 있습니다.
- Azure CLI를 설치하고 로그인하여 사용자 고유의 셸 환경을 또는
- 웹 브라우저에서 Azure Portal 또는
테스트 환경에 로그인되어 있는지 확인합니다.
포털의 계정 정보를 사용하여 현재 컨텍스트를 확인합니다.
Azure Portal 계정 정보를 보여 주는 화면 캡처
-
az account show
사용하여 현재 컨텍스트를 볼 수 있습니다. 로그인하거나 컨텍스트를 변경하려면 az account login
사용합니다.
리소스 그룹 만들기
이 예제에서 eastus
위치를 선택하는 것은 중요하지 않습니다. 사용 가능한 모든 Azure 위치를 사용할 수 있습니다.
az group create --name sshdemo01 --___location eastus
리소스 그룹에 정책 할당
이 빠른 시작에서는 기본 제공 정책 정의 Configure SSH Posture Control on Linux machines
사용하여 감사 및 구성 동작을 적용합니다.
예제 할당은 제한된 사용자 지정(배너 텍스트)을 사용하여 SSH Posture Control 기본값(예: 포트 22, 루트 액세스 허용 안 됨)을 주로 사용합니다.
- 정책으로 이동한 다음 정의
- 목록을 필터링하여
Configure SSH Posture Control on Linux machines
찾아 선택합니다.
- 정책 정의 페이지에서 할당을 클릭합니다.
- 정책 할당 워크플로에서
- 새 빈 리소스 그룹(이전에 만든)을 범위로 선택합니다.
- 선택 사항: 이 정책 할당의 이름을 선택합니다. 기본적으로 정책 정의의 이름이 사용됩니다.
- 선택 사항: 매개 변수 탭에서 "배너" 값과 같은 기본값을 재정의합니다.
- 참고: 시나리오 감사 및 구성을 위한 적절한 기능과 규정 준수를 보장하기 위해 규칙 '포트'를 단일 값으로 구성해야 합니다.
- 정책 할당 만들기를 완료합니다.
# Note this example is from a bash shell. Other shells may require different handling of special characters and variables
RG_ID=$(az group show --resource-group sshdemo01 --query id --output tsv)
az policy assignment create --policy "e22a2f03-0534-4d10-8ea0-aa25a6113233" --name "Configure SSH Posture test machine" --scope "$RG_ID" --params '{"banner":{"value":"CONTOSO SYSTEMS. Unauthorized use will be prosecuted."}}' --mi-system-assigned --role "Guest Configuration Resource Contributor" --identity-scope "$RG_ID" --___location eastus
주의
포털 또는 CLI를 사용했는지 여부에 관계없이 계속하기 전에 방금 만든 정책 할당의 범위를 검사합니다. 범위가 이전에 만든 새 빈 리소스 그룹이 아닌 다른 항목으로 잘못 설정된 경우 의도하지 않은 머신을 구성하지 않도록 즉시 수정해야 합니다.
테스트 VM을 만들고 컴퓨터 구성을 준비합니다.
- Linux 가상 머신 만들기
- 시스템 할당 ID를 추가합니다(아직 없는 경우).
- 컴퓨터 구성 확장 추가(포털에서 Linux용 Azure Machine Configuration으로 레이블 지정)
시스템 할당 ID를 사용하여 Linux VM 만들기
az vm create --name sshdemo01 --resource-group sshdemo01 --image Ubuntu2204 --assign-identity [system]
Azure VM 확장으로 Machine Configuration 에이전트 설치
az vm extension set --resource-group sshdemo01 --vm-name sshdemo01 --name ConfigurationForLinux --publisher Microsoft.GuestConfiguration --enable-auto-upgrade
팁
이 빠른 시작에서는 VM을 만드는 동안 컴퓨터 구성(VM에 관리 ID 및 에이전트 확장이 포함됨)에 대한 필수 구성 요소가 직접 해결되었습니다. 대규모로 이러한 필수 구성 요소는 Deploy prerequisites to enable Guest Configuration policies on virtual machines
기본 제공 정책 이니셔티브를 사용하여 충족할 수 있습니다.
계속하기 전에 휴식을 취하십시오.
이제 몇 가지 단계가 자동으로 수행됩니다. 이러한 각 단계는 몇 분 정도 걸릴 수 있습니다. 따라서 계속하기 전에 15분 이상 기다려 주세요.
결과 관찰
다음 단계를 사용하여 다음을 확인할 수 있습니다.
- 호환되는 컴퓨터 수(또는 그렇지 않음)
- 수천 대의 컴퓨터가 있을 수 있는 프로덕션 규모에서 특히 유용합니다.
- 호환되는 컴퓨터(또는 그렇지 않음)
- 지정된 컴퓨터의 경우 개별 규칙이 규정을 준수하는지 여부
다음 Azure CLI 예제는 bash 환경에서 제공됩니다. 다른 셸 환경을 사용하려면 줄 끝 동작, 따옴표 규칙, 문자 이스케이프 등에 대한 예제를 조정해야 할 수 있습니다.
규정을 준수하는 컴퓨터 수(또는 그렇지 않음):
QUERY="guestconfigurationresources
| where name contains 'LinuxSshServerSecurityBaseline'
| extend complianceStatus = tostring(properties.complianceStatus)
| summarize machineCount = count() by complianceStatus
"
az graph query -q "$QUERY" --query data --output table
# Sample output from an environment with two machines:
#
# complianceStatus machineCount
# ---------------- ------------
# Pending 1
# Compliant 1
어떤 머신이 규정을 준수하는지 여부:
QUERY="guestconfigurationresources
| where name contains 'LinuxSshServerSecurityBaseline'
| project
machine = split(properties.targetResourceId,'/')[-1],
complianceStatus = properties.complianceStatus,
lastComplianceStatusChecked = properties.lastComplianceStatusChecked
"
az graph query -q "$QUERY" --query data --output table
# Sample output from an environment with two machines:
#
# machine complianceStatus lastComplianceStatusChecked
# ------- ---------------- ---------------------------
# sshdemovm01 Compliant 2/15/2024 11:07:21 PM
# sshdemovm02 Pending 1/1/0001 12:00:00 AM
지정된 컴퓨터의 경우 개별 규칙이 규정을 준수하는지 여부:
QUERY="GuestConfigurationResources
| where name contains 'LinuxSshServerSecurityBaseline'
| project report = properties.latestAssignmentReport,
machine = split(properties.targetResourceId,'/')[-1],
lastComplianceStatusChecked=properties.lastComplianceStatusChecked
| mv-expand report.resources
| project machine,
rule = report_resources.resourceId,
ruleComplianceStatus = report_resources.complianceStatus,
ruleComplianceReason = report_resources.reasons[0].phrase,
lastComplianceStatusChecked
"
az graph query -q "$QUERY" --query data --output table
# Sample output from an environment where audit-and-configure behavior was selected, such that all settings became compliant:
#
# machine rule ruleComplianceStatus ruleComplianceReason
# ------- --------------- ------ ------
# sshdemovm01 Ensure permissions on /etc/ssh/sshd_config are configured true Access to '/etc/ssh/sshd_config' matches required ...
# sshdemovm01 Ensure SSH is configured to meet best practices (protocol 2) true 'Protocol 2' is found uncommented in /etc/ssh/sshd_config
# sshdemovm01 Ensure SSH is configured to ignore rhosts true The sshd service reports that 'ignorerhosts' is set to 'yes'
# sshdemovm01 Ensure SSH LogLevel is set to INFO true The sshd service reports that 'loglevel' is set to 'INFO'
# sshdemovm01 Ensure SSH MaxAuthTries is configured true The sshd service reports that 'maxauthtries' is set to '6'
# sshdemovm01 Ensure allowed users for SSH access are configured true The sshd service reports that 'allowusers' is set to '*@*'
# sshdemovm01 Ensure denied users for SSH are configured true The sshd service reports that 'denyusers' is set to 'root'
# sshdemovm01 Ensure allowed groups for SSH are configured true The sshd service reports that 'allowgroups' is set to '*'
# sshdemovm01 Ensure denied groups for SSH are configured true The sshd service reports that 'denygroups' is set to 'root'
# sshdemovm01 Ensure SSH host-based authenticationis disabled true The sshd service reports that 'hostbasedauthentication' is ...
# ...
선택 사항: 크기 조정을 경험하기 위해 더 많은 테스트 머신 추가
이 문서에서 정책은 처음에 비어 있던 리소스 그룹에 할당된 다음 하나의 VM을 얻었습니다. 이는 시스템이 종단 간 작동함을 보여 주지만 대규모 작업 감각을 제공하지는 않습니다. 예를 들어 정책 할당 준수 보기에서 한 컴퓨터의 원형 차트는 인위적으로 느껴질 수 있습니다.
수동으로 또는 자동화를 통해 리소스 그룹에 더 많은 테스트 머신을 추가하는 것이 좋습니다. Azure VM 또는 Arc 지원 컴퓨터일 수 있습니다. 이러한 컴퓨터가 규정 준수(또는 실패)되는 것을 볼 때 SSH Posture Control을 대규모로 운용하는 데 더 예리한 감각을 얻을 수 있습니다.
선택 사항: 테스트 머신을 수동으로 검사하여 결과 확인
SSH Posture Control과 같은 새로운 기능을 시작할 때 대역 외 결과를 수동으로 검사하는 것이 중요할 수 있습니다. 이렇게 하면 신뢰도와 명확성을 구축할 수 있습니다. 예를 들어 이 문서의 단계는 테스트 VM에서 수정된 로그온 배너 구성을 초래해야 합니다. 배너를 보려면 컴퓨터에 대한 SSH 연결을 시도하거나 sshd_config 파일을 검사하여 이를 확인할 수 있습니다.
리소스 정리
지속적인 요금을 방지하려면 이 문서에 사용된 리소스 그룹을 삭제하는 것이 좋습니다. 예를 들어 Azure CLI 명령은 az group delete --name "sshdemo01"
관련 콘텐츠