Skip to content

Commit 6993b3f

Browse files
authored
Merge pull request #311240 from asudbring/tsk544790-sfi-ssh
Fix port in diagram
2 parents 1c997e3 + 66e0c07 commit 6993b3f

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

59 Bytes
Loading

articles/virtual-network/tutorial-filter-network-traffic.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -579,22 +579,23 @@ Generate SSH keys in Azure with [New-AzSshKey](/powershell/module/az.compute/new
579579
$webSshKeyParams = @{
580580
ResourceGroupName = "test-rg"
581581
Name = "vm-web-key"
582-
Location = "westus2"
583582
}
584583
New-AzSshKey @webSshKeyParams
585584
586585
# Create SSH key for vm-mgmt
587586
$mgmtSshKeyParams = @{
588587
ResourceGroupName = "test-rg"
589588
Name = "vm-mgmt-key"
590-
Location = "westus2"
591589
}
592590
New-AzSshKey @mgmtSshKeyParams
593591
```
594592

595593
Create a VM configuration with [New-AzVMConfig](/powershell/module/az.compute/new-azvmconfig), then create the VM with [New-AzVM](/powershell/module/az.compute/new-azvm). The following example creates a VM that serves as a web server. The `-AsJob` option creates the VM in the background, so you can continue to the next step:
596594

597595
```azurepowershell-interactive
596+
# Get the SSH public key
597+
$sshKey = Get-AzSshKey -Name "vm-web-key" -ResourceGroupName "test-rg"
598+
598599
$webVmConfigParams = @{
599600
VMName = "vm-web"
600601
VMSize = "Standard_DS1_V2"
@@ -607,21 +608,29 @@ $vmImageParams = @{
607608
Version = "latest"
608609
}
609610
610-
$webVmConfig = New-AzVMConfig @webVmConfigParams | Set-AzVMOperatingSystem -Linux -ComputerName "vm-web" | Set-AzVMSourceImage @vmImageParams | Add-AzVMNetworkInterface -Id $webNic.Id | Set-AzVMOSDisk -CreateOption FromImage -Linux | Set-AzVMBootDiagnostic -Disable
611+
$webVmConfig = New-AzVMConfig @webVmConfigParams | `
612+
Set-AzVMOperatingSystem -Linux -ComputerName "vm-web" -Credential (New-Object System.Management.Automation.PSCredential("azureuser", (ConvertTo-SecureString "DummyP@ssw0rd" -AsPlainText -Force))) -DisablePasswordAuthentication | `
613+
Set-AzVMSourceImage @vmImageParams | `
614+
Add-AzVMNetworkInterface -Id $webNic.Id | `
615+
Set-AzVMOSDisk -CreateOption FromImage | `
616+
Set-AzVMBootDiagnostic -Disable | `
617+
Add-AzVMSshPublicKey -KeyData $sshKey.publicKey -Path "/home/azureuser/.ssh/authorized_keys"
611618
612619
$webVmParams = @{
613620
ResourceGroupName = "test-rg"
614621
Location = "westus2"
615622
VM = $webVmConfig
616-
SshKeyName = "vm-web-key"
617623
}
618624
619-
New-AzVM @webVmParams -GenerateSshKey -AsJob
625+
New-AzVM @webVmParams -AsJob
620626
```
621627

622628
Create a VM to serve as a management server:
623629

624630
```azurepowershell-interactive
631+
# Get the SSH public key
632+
$sshKey = Get-AzSshKey -Name "vm-mgmt-key" -ResourceGroupName "test-rg"
633+
625634
$mgmtVmConfigParams = @{
626635
VMName = "vm-mgmt"
627636
VMSize = "Standard_DS1_V2"
@@ -634,16 +643,21 @@ $vmImageParams = @{
634643
Version = "latest"
635644
}
636645
637-
$mgmtVmConfig = New-AzVMConfig @mgmtVmConfigParams | Set-AzVMOperatingSystem -Linux -ComputerName "vm-mgmt" | Set-AzVMSourceImage @vmImageParams | Add-AzVMNetworkInterface -Id $mgmtNic.Id | Set-AzVMOSDisk -CreateOption FromImage -Linux | Set-AzVMBootDiagnostic -Disable
646+
$mgmtVmConfig = New-AzVMConfig @mgmtVmConfigParams | `
647+
Set-AzVMOperatingSystem -Linux -ComputerName "vm-mgmt" -Credential (New-Object System.Management.Automation.PSCredential("azureuser", (ConvertTo-SecureString "DummyP@ssw0rd" -AsPlainText -Force))) -DisablePasswordAuthentication | `
648+
Set-AzVMSourceImage @vmImageParams | `
649+
Add-AzVMNetworkInterface -Id $mgmtNic.Id | `
650+
Set-AzVMOSDisk -CreateOption FromImage | `
651+
Set-AzVMBootDiagnostic -Disable | `
652+
Add-AzVMSshPublicKey -KeyData $sshKey.publicKey -Path "/home/azureuser/.ssh/authorized_keys"
638653
639654
$mgmtVmParams = @{
640655
ResourceGroupName = "test-rg"
641656
Location = "westus2"
642657
VM = $mgmtVmConfig
643-
SshKeyName = "vm-mgmt-key"
644658
}
645659
646-
New-AzVM @mgmtVmParams -GenerateSshKey
660+
New-AzVM @mgmtVmParams
647661
```
648662

649663
The virtual machine takes a few minutes to create. Don't continue with the next step until Azure finishes creating the VM.

0 commit comments

Comments
 (0)