Skip to content

Commit e93721d

Browse files
Merge pull request #292861 from asudbring/us354428-exec-docs-conversion
SSH Key config for Linux VMs for PoSh and CLI
2 parents a3276ce + 224ca6e commit e93721d

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

articles/virtual-network/create-virtual-machine-accelerated-networking.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ Accelerated networking is enabled in the portal during virtual machine creation.
374374
Use [New-AzNetworkInterface](/powershell/module/az.Network/New-azNetworkInterface) to create a network interface (NIC) with Accelerated Networking enabled, and assign the public IP address to the NIC.
375375

376376
```azurepowershell
377-
$vnet = Get-AzVirtualNetwork -ResourceGroupName "test-rg" -Name "vnet-1"
377+
$vnetParams = @{
378+
ResourceGroupName = "test-rg"
379+
Name = "vnet-1"
380+
}
381+
$vnet = Get-AzVirtualNetwork @vnetParams
378382
379383
$nicParams = @{
380384
ResourceGroupName = "test-rg"
@@ -471,6 +475,9 @@ Use [Get-Credential](/powershell/module/microsoft.powershell.security/get-creden
471475
$cred = Get-Credential
472476
```
473477

478+
> [!NOTE]
479+
> A username is required for the VM. The password is optional and won't be used if set. SSH key configuration is recommended for Linux VMs.
480+
474481
Use [New-AzVMConfig](/powershell/module/az.compute/new-azvmconfig) to define a VM with a VM size that supports accelerated networking, as listed in [Windows Accelerated Networking](https://azure.microsoft.com/updates/accelerated-networking-in-expanded-preview). For a list of all Windows VM sizes and characteristics, see [Windows VM sizes](/azure/virtual-machines/sizes).
475482
476483
```azurepowershell
@@ -489,7 +496,7 @@ $osParams = @{
489496
ComputerName = "vm-1"
490497
Credential = $cred
491498
}
492-
$vmConfig = Set-AzVMOperatingSystem @osParams -Linux
499+
$vmConfig = Set-AzVMOperatingSystem @osParams -Linux -DisablePasswordAuthentication
493500
494501
$imageParams = @{
495502
VM = $vmConfig
@@ -518,23 +525,24 @@ $vmConfigParams = @{
518525
$vmConfig = Add-AzVMNetworkInterface @vmConfigParams
519526
```
520527
521-
Use [New-AzVM](/powershell/module/az.compute/new-azvm) to create the VM with Accelerated Networking enabled.
528+
Use [New-AzVM](/powershell/module/az.compute/new-azvm) to create the VM with Accelerated Networking enabled. The command will generate SSH keys for the virtual machine for login. Make note of the location of the private key. The private key is needed in later steps for connecting to the virtual machine with Azure Bastion.
522529
523530
```azurepowershell
524531
$vmParams = @{
525532
VM = $vmConfig
526533
ResourceGroupName = "test-rg"
527534
Location = "eastus2"
535+
SshKeyName = "ssh-key"
528536
}
529-
New-AzVM @vmParams
537+
New-AzVM @vmParams -GenerateSshKey
530538
```
531539
532540
### [CLI](#tab/cli)
533541
534542
Use [az vm create](/cli/azure/vm#az-vm-create) to create the VM, and use the `--nics` option to attach the NIC you created. Ensure you select a VM size and distribution listed in [Windows and Linux Accelerated Networking](https://azure.microsoft.com/updates/accelerated-networking-in-expanded-preview). For a list of all VM sizes and characteristics, see [Sizes for virtual machines in Azure](/azure/virtual-machines/sizes).
535543
536544
537-
The following example creates a VM with a size that supports Accelerated Networking, Standard_DS4_v2.
545+
The following example creates a VM with a size that supports Accelerated Networking, Standard_DS4_v2. The command will generate SSH keys for the virtual machine for login. Make note of the location of the private key. The private key is needed in later steps for connecting to the virtual machine with Azure Bastion.
538546
539547
```bash
540548
export RESOURCE_GROUP_NAME="test-rg$RANDOM_SUFFIX"
@@ -550,7 +558,7 @@ az vm create \
550558
--image $IMAGE \
551559
--size $SIZE \
552560
--admin-username $ADMIN_USER \
553-
--authentication-type password \
561+
--generate-ssh-keys \
554562
--nics $NIC_NAME
555563
```
556564
@@ -587,7 +595,13 @@ Results:
587595
588596
1. On the VM's **Overview** page, select **Connect** then **Connect via Bastion**.
589597

590-
1. Enter the username and password you used when you created the VM, and then select **Connect**.
598+
1. In the Bastion connection screen, change **Authentication Type** to **SSH Private Key from Local File**.
599+
600+
1. Enter the **Username** that you used when creating the virtual machine. In this example, the user is named **azureuser**, replace with the username you created.
601+
602+
1. In **Local File**, select the folder icon and browse to the private key file that was generated when you created the VM. The private key file is typically named `id_rsa` or `id_rsa.pem`.
603+
604+
1. Select **Connect**.
591605

592606
1. A new browser window opens with the Bastion connection to your VM.
593607

0 commit comments

Comments
 (0)