Skip to content

Commit 7294ca0

Browse files
author
Jill Grant
authored
Merge pull request #277064 from vamckMS/linux-ed25519-update-vakavuru
update-linux-docs-ed25519
2 parents bbf574f + 850d09c commit 7294ca0

File tree

8 files changed

+140
-13
lines changed

8 files changed

+140
-13
lines changed

articles/virtual-machines/linux-vm-connect.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ When hosting a Linux virtual machine on Azure, the most common method for access
1616

1717
This document describes how to connect, via SSH, to a VM that has a public IP. If you need to connect to a VM without a public IP, see [Azure Bastion Service](../bastion/bastion-overview.md).
1818

19+
> [!Note]
20+
> ED25519 SSH key support for Linux VMs is now in preview in all regions including sovereign clouds. However, Azure portal support for ED25519 is limited to Azure public cloud regions only.
21+
1922
## Prerequisites
2023

2124
- You need an SSH key pair. If you don't already have one, Azure creates a key pair during the deployment process. If you need help with creating one manually, see [Create and use an SSH public-private key pair for Linux VMs in Azure](./linux/mac-create-ssh-keys.md).
@@ -61,7 +64,7 @@ If you're having trouble connecting, you can also use portal:
6164
Once the above prerequisites are met, you're ready to connect to your VM. Open your SSH client of choice. The SSH client command is typically included in Linux, macOS, and Windows. If you're using Windows 7 or older, where Win32 OpenSSH isn't included by default, consider installing [WSL](/windows/wsl/about) or using [Azure Cloud Shell](../cloud-shell/overview.md) from the browser.
6265

6366
> [!NOTE]
64-
> The following examples assume the SSH key is in the key.pem format. If you used CLI or Azure PowerShell to download your keys, they may be in the id_rsa format.
67+
> The following examples assume the SSH key is in the key.pem format. If you used CLI or Azure PowerShell to download your keys, they may be in the id_rsa or ED25519 format.
6568
6669
## [WSL, macOS, or native Linux client](#tab/Linux)
6770

articles/virtual-machines/linux/create-ssh-keys-detailed.md

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ ms.custom: GGAL-freshness822, linux-related-content
1717

1818
With a secure shell (SSH) key pair, you can create a Linux virtual machine that uses SSH keys for authentication. This article shows you how to create and use an SSH RSA public-private key file pair for SSH client connections.
1919

20-
If you want quick commands rather than a more in-depth explaination of SSH keys, see [How to create an SSH public-private key pair for Linux VMs in Azure](mac-create-ssh-keys.md).
20+
If you want quick commands rather than a more in-depth explanation of SSH keys, see [How to create an SSH public-private key pair for Linux VMs in Azure](mac-create-ssh-keys.md).
2121

2222
To create SSH keys and use them to connect to a Linux VM from a **Windows** computer, see [How to use SSH keys with Windows on Azure](ssh-from-windows.md). You can also use the [Azure portal](../ssh-keys-portal.md) to create and manage SSH keys for creating VMs in the portal.
2323

24+
> [!Note]
25+
> ED25519 SSH key support for Linux VMs is now in preview in all regions including sovereign clouds. However, Azure portal support for ED25519 is limited to Azure public cloud regions only.
26+
2427
[!INCLUDE [virtual-machines-common-ssh-overview](../../../includes/virtual-machines-common-ssh-overview.md)]
2528

2629
[!INCLUDE [virtual-machines-common-ssh-support](../../../includes/virtual-machines-common-ssh-support.md)]
@@ -48,6 +51,12 @@ The following `ssh-keygen` command generates 4096-bit SSH RSA public and private
4851
ssh-keygen -m PEM -t rsa -b 4096
4952
```
5053

54+
The following `ssh-keygen` command generates 256-bit ED25519 public and private key files by default in the `~/.ssh` directory. If an existing SSH key pair is found in the current location, those files are overwritten.
55+
56+
```bash
57+
ssh-keygen -m PEM -t ed25519
58+
```
59+
5160
### Detailed example
5261
The following example shows additional command options to create an SSH RSA key pair. If an SSH key pair exists in the current location, those files are overwritten.
5362

@@ -57,10 +66,19 @@ ssh-keygen \
5766
-t rsa \
5867
-b 4096 \
5968
-C "azureuser@myserver" \
60-
-f ~/.ssh/mykeys/myprivatekey \
69+
-f ~/.ssh/mykeys/myrsaprivatekey \
6170
-N mypassphrase
6271
```
72+
The following example shows additional command options to create an SSH ED25519 key pair. If an SSH key pair exists in the current location, those files are overwritten.
6373

74+
```bash
75+
ssh-keygen \
76+
-m PEM \
77+
-t ed25519 \
78+
-C "azureuser@myserver" \
79+
-f ~/.ssh/mykeys/myedprivatekey \
80+
-N mypassphrase
81+
```
6482
**Command explained**
6583

6684
`ssh-keygen` = the program used to create the keys
@@ -77,7 +95,7 @@ ssh-keygen \
7795

7896
`-N mypassphrase` = an additional passphrase used to access the private key file.
7997

80-
### Example of ssh-keygen
98+
### Example of ssh-keygen (RSA)
8199

82100
```bash
83101
ssh-keygen -t rsa -m PEM -b 4096 -C "azureuser@myserver"
@@ -102,23 +120,61 @@ The key's randomart image is:
102120
| .. |
103121
+----[SHA256]-----+
104122
```
123+
### Example of ssh-keygen (ED25519)
124+
125+
```bash
126+
ssh-keygen -t ed25519 -m PEM -C "azureuser@myserver"
127+
Generating public/private rsa key pair.
128+
Enter file in which to save the key (/home/azureuser/.ssh/id_rsa):
129+
Enter passphrase (empty for no passphrase):
130+
Enter same passphrase again:
131+
Your identification has been saved in /home/azureuser/.ssh/id_ed25519.
132+
Your public key has been saved in /home/azureuser/.ssh/id_ed25519.pub.
133+
The key fingerprint is:
134+
SHA256:vFfHHrpSGQBd/oNdvNiX0sG9Vh+wROlZBktNZw9AUjA azureuser@myserver
135+
The key's randomart image is:
136+
+---[ED25519 256]----+
137+
| |
138+
|.. . |
139+
|o+.o . |
140+
|*=o o o + + |
141+
|*+o+ oSB + o |
142+
|**++o.+oo = . |
143+
|=+*..*.o E |
144+
|.. o o.. |
145+
| .o. |
146+
+----[SHA256]-----+
147+
```
105148

106149
#### Saved key files
107150

108151
`Enter file in which to save the key (/home/azureuser/.ssh/id_rsa): ~/.ssh/id_rsa`
109152

110-
The key pair name for this article. Having a key pair named `id_rsa` is the default; some tools might expect the `id_rsa` private key file name, so having one is a good idea. The directory `~/.ssh/` is the default location for SSH key pairs and the SSH config file. If not specified with a full path, `ssh-keygen` creates the keys in the current working directory, not the default `~/.ssh`.
153+
or
154+
155+
`Enter file in which to save the key (/home/azureuser/.ssh/id_ed25519): ~/.ssh/id_ed25519`
156+
157+
158+
The default key pair names for RSA and ED25519 are `id_rsa` and `id_ed25519` respectively; some tools might expect the `id_rsa` or `id_ed25519` private key file name, so having one is a good idea. The directory `~/.ssh/` is the default location for SSH key pairs and the SSH config file. If not specified with a full path, `ssh-keygen` creates the keys in the current working directory, not the default `~/.ssh`.
111159

112160
#### List of the `~/.ssh` directory
113161

114162
To view existing files in the `~/.ssh` directory, run the following command. If no files are found in the directory or the directory itself is missing, make sure that all previous commands were successfully run. You may require root access to modify files in this directory on certain Linux distributions.
115163

164+
RSA Key pair:
116165
```bash
117166
ls -al ~/.ssh
118167
-rw------- 1 azureuser staff 1675 Aug 25 18:04 id_rsa
119168
-rw-r--r-- 1 azureuser staff 410 Aug 25 18:04 id_rsa.pub
120169
```
121170

171+
ED25519 Key pair:
172+
```bash
173+
ls -al ~/.ssh
174+
-rw------- 1 azureuser staff 1675 Aug 25 18:04 id_ed25519
175+
-rw-r--r-- 1 azureuser staff 410 Aug 25 18:04 id_ed25519.pub
176+
```
177+
122178
#### Key passphrase
123179

124180
`Enter passphrase (empty for no passphrase):`
@@ -129,12 +185,16 @@ It is *strongly* recommended to add a passphrase to your private key. Without a
129185

130186
If you use the [Azure CLI](/cli/azure) to create your VM, you can optionally generate both public and private SSH key files by running the [az vm create](/cli/azure/vm) command with the `--generate-ssh-keys` option. The keys are stored in the ~/.ssh directory. Note that this command option does not overwrite keys if they already exist in that location, such as with some pre-configured Compute Gallery images.
131187

188+
> [!NOTE]
189+
> [az sshkey create](/cli/azure/sshkey#az-sshkey-create) command deafults to RSA encryption and cannot be use to generate ED25519 key pairs, however you can create a ED25519 key pair using ssh-keygen as described above and then use that public key to create a VM.
190+
132191
## Provide SSH public key when deploying a VM
133192

134193
To create a Linux VM that uses SSH keys for authentication, provide your SSH public key when creating the VM using the Azure portal, CLI, Resource Manager templates, or other methods. When using the portal, you enter the public key itself. If you use the [Azure CLI](/cli/azure) to create your VM with an existing public key, specify the value or location of this public key by running the [az vm create](/cli/azure/vm) command with the `--ssh-key-value` option.
135194

136195
If you're not familiar with the format of an SSH public key, you can see your public key by running `cat` as follows, replacing `~/.ssh/id_rsa.pub` with your own public key file location:
137196

197+
### RSA key pair
138198
```bash
139199
cat ~/.ssh/id_rsa.pub
140200
```
@@ -149,7 +209,7 @@ If you copy and paste the contents of the public key file into the Azure portal
149209

150210
If you prefer to use a public key that is in a multiline format, you can generate an RFC4716 formatted key in a 'pem' container from the public key you previously created.
151211

152-
To create a RFC4716 formatted key from an existing SSH public key:
212+
To create an RFC4716 formatted key from an existing SSH public key:
153213

154214
```bash
155215
ssh-keygen \
@@ -158,6 +218,30 @@ ssh-keygen \
158218
-m RFC4716 > ~/.ssh/id_ssh2.pem
159219
```
160220

221+
### ED25519 key pair
222+
```bash
223+
cat ~/.ssh/id_ed25519.pub
224+
```
225+
226+
Output is similar to the following (redacted example below):
227+
228+
```
229+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP6I5JuhGq3RidMNpxrplIQwEfc4Rh7UyV8JYYH2U2xA azureuser@myserver
230+
```
231+
232+
If you copy and paste the contents of the public key file into the Azure portal or a Resource Manager template, make sure you don't copy any additional whitespace or introduce additional line breaks. For example, if you use macOS, you can pipe the public key file (by default, `~/.ssh/id_ed25519.pub`) to **pbcopy** to copy the contents (there are other Linux programs that do the same thing, such as `xclip`).
233+
234+
If you prefer to use a public key that is in a multiline format, you can generate an RFC4716 formatted key in a 'pem' container from the public key you previously created.
235+
236+
To create a PEM formatted key from an existing SSH public key:
237+
238+
```bash
239+
ssh-keygen \
240+
-f ~/.ssh/id_ed25519.pub \
241+
-e \
242+
-m RFC4716 > ~/.ssh/id_edssh.pem
243+
```
244+
161245
## SSH to your VM with an SSH client
162246
With the public key deployed on your Azure VM, and the private key on your local system, SSH to your VM using the IP address or DNS name of your VM. Replace *azureuser* and *myvm.westus.cloudapp.azure.com* in the following command with the administrator user name and the fully qualified domain name (or IP address):
163247

@@ -184,6 +268,11 @@ Now add the private key to `ssh-agent` using the command `ssh-add`.
184268
```bash
185269
ssh-add ~/.ssh/id_rsa
186270
```
271+
or
272+
273+
```bash
274+
ssh-add ~/.ssh/id_ed25519
275+
```
187276

188277
The private key passphrase is now stored in `ssh-agent`.
189278

articles/virtual-machines/linux/mac-create-ssh-keys.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,23 @@ For additional ways to generate and use SSH keys on a Windows computer, see [How
2828

2929
[!INCLUDE [virtual-machines-common-ssh-support](../../../includes/virtual-machines-common-ssh-support.md)]
3030

31+
> [!Note]
32+
> ED25519 SSH key support for Linux VMs is now in preview in all regions including sovereign clouds. However, Azure portal support for ED25519 is limited to Azure public cloud regions only.
33+
3134
## Create an SSH key pair
3235

3336
Use the `ssh-keygen` command to generate SSH public and private key files. By default, these files are created in the ~/.ssh directory. You can specify a different location, and an optional password (*passphrase*) to access the private key file. If an SSH key pair with the same name exists in the given location, those files are overwritten.
3437

3538
The following command creates an SSH key pair using RSA encryption and a bit length of 4096:
3639

3740
```bash
38-
ssh-keygen -m PEM -t rsa -b 4096
41+
ssh-keygen -m PEM -t rsa -b 4096 -f ~/.ssh/id_rsa.pem
42+
```
43+
44+
The following command creates an SSH key pair using ED25519 encryption with a fixed length of 256 bits:
45+
46+
```bash
47+
ssh-keygen -m PEM -t ed25519 -f ~/.ssh/id_ed25519.pem
3948
```
4049

4150
> [!NOTE]
@@ -47,6 +56,9 @@ If you use the [Azure CLI](/cli/azure) to create your VM with the [az vm create]
4756
az vm create --name VMname --resource-group RGname --image Ubuntu2204 --generate-ssh-keys
4857
```
4958

59+
> [!NOTE]
60+
> [az sshkey create](/cli/azure/sshkey#az-sshkey-create) command deafults to RSA encryption and cannot be use to generate ED25519 key pairs, however you can create a ED25519 key pair using ssh-keygen as described above and then use that public key to create a VM.
61+
5062
## Provide an SSH public key when deploying a VM
5163

5264
To create a Linux VM that uses SSH keys for authentication, specify your SSH public key when creating the VM using the Azure portal, Azure CLI, Azure Resource Manager templates, or other methods:
@@ -57,19 +69,28 @@ To create a Linux VM that uses SSH keys for authentication, specify your SSH pub
5769

5870
If you're not familiar with the format of an SSH public key, you can display your public key with the following `cat` command, replacing `~/.ssh/id_rsa.pub` with the path and filename of your own public key file if needed:
5971

72+
### RSA key pair
6073
```bash
6174
cat ~/.ssh/id_rsa.pub
6275
```
63-
64-
A typical public key value looks like this example:
76+
A typical RSA public key value looks like this example:
6577

6678
```output
6779
ssh-rsa AAAAB3NzaC1yc2EAABADAQABAAACAQC1/KanayNr+Q7ogR5mKnGpKWRBQU7F3Jjhn7utdf7Z2iUFykaYx+MInSnT3XdnBRS8KhC0IP8ptbngIaNOWd6zM8hB6UrcRTlTpwk/SuGMw1Vb40xlEFphBkVEUgBolOoANIEXriAMvlDMZsgvnMFiQ12tD/u14cxy1WNEMAftey/vX3Fgp2vEq4zHXEliY/sFZLJUJzcRUI0MOfHXAuCjg/qyqqbIuTDFyfg8k0JTtyGFEMQhbXKcuP2yGx1uw0ice62LRzr8w0mszftXyMik1PnshRXbmE2xgINYg5xo/ra3mq2imwtOKJpfdtFoMiKhJmSNHBSkK7vFTeYgg0v2cQ2+vL38lcIFX4Oh+QCzvNF/AXoDVlQtVtSqfQxRVG79Zqio5p12gHFktlfV7reCBvVIhyxc2LlYUkrq4DHzkxNY5c9OGSHXSle9YsO3F1J5ip18f6gPq4xFmo6dVoJodZm9N0YMKCkZ4k1qJDESsJBk2ujDPmQQeMjJX3FnDXYYB182ZCGQzXfzlPDC29cWVgDZEXNHuYrOLmJTmYtLZ4WkdUhLLlt5XsdoKWqlWpbegyYtGZgeZNRtOOdN6ybOPJqmYFd2qRtb4sYPniGJDOGhx4VodXAjT09omhQJpE6wlZbRWDvKC55R2d/CSPHJscEiuudb+1SG2uA/oik/WQ== username@domainname
6880
```
81+
### ED25519 key pair
82+
```bash
83+
cat ~/.ssh/id_ed25519.pub
84+
```
85+
A typical ED25519 public key value looks like this example:
86+
87+
```output
88+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRjWGWLeiUQ3U9fNnCsNpXIyACpD/Jbm09OZGsz3DIM username@domainname
89+
```
6990

7091
If you copy and paste the contents of the public key file to use in the Azure portal or a Resource Manager template, make sure you don't copy any trailing whitespace. To copy a public key in macOS, you can pipe the public key file to `pbcopy`. Similarly in Linux, you can pipe the public key file to programs such as `xclip`.
7192

72-
The public key that you place on your Linux VM in Azure is by default stored in ~/.ssh/id_rsa.pub, unless you specified a different location when you created the key pair. To use the [Azure CLI 2.0](/cli/azure) to create your VM with an existing public key, specify the value and optionally the location of this public key using the [az vm create](/cli/azure/vm#az-vm-create) command with the `--ssh-key-values` option. In the following command, replace *myVM*, *myResourceGroup*, *UbuntuLTS*, *azureuser*, and *mysshkey.pub* with your own values:
93+
The public key that you place on your Linux VM in Azure is by default stored under ``~/.ssh/`` directory, unless you specified a different location when you created the key pair. To use the [Azure CLI 2.0](/cli/azure) to create your VM with an existing public key, specify the value and optionally the location of this public key using the [az vm create](/cli/azure/vm#az-vm-create) command with the `--ssh-key-values` option. In the following command, replace *myVM*, *myResourceGroup*, *UbuntuLTS*, *azureuser*, and *mysshkey.pub* with your own values:
7394

7495
```azurecli-interactive
7596
az vm create \

articles/virtual-machines/linux/ssh-from-windows.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ This article is for Windows users who want to [create](#create-an-ssh-key-pair)
2020

2121
To use SSH keys from a Linux or macOS client, see the [quick steps](mac-create-ssh-keys.md). For a more detailed overview of SSH, see [Detailed steps: Create and manage SSH keys for authentication to a Linux VM in Azure](create-ssh-keys-detailed.md).
2222

23+
> [!Note]
24+
> ED25519 SSH key support for Linux VMs is now in preview in all regions including sovereign clouds. However, Azure portal support for ED25519 is limited to Azure public cloud regions only.
25+
2326
## Overview of SSH and keys
2427

2528
[SSH](https://www.ssh.com/ssh/) is an encrypted connection protocol that allows secure sign-ins over unsecured connections. SSH is the default connection protocol for Linux VMs hosted in Azure. Although SSH itself provides an encrypted connection, using passwords with SSH still leaves the VM vulnerable to brute-force attacks. We recommend connecting to a VM over SSH using a public-private key pair, also known as *SSH keys*.
@@ -38,6 +41,9 @@ Your public key can be shared with anyone, but only you (or your local security
3841

3942
[!INCLUDE [virtual-machines-common-ssh-support](../../../includes/virtual-machines-common-ssh-support.md)]
4043

44+
> [!NOTE]
45+
> During preview, ED25519 keys can only be used with Linux VMs.
46+
4147
## SSH clients
4248

4349
Recent versions of Windows 10 include [OpenSSH client commands](https://blogs.msdn.microsoft.com/commandline/2018/03/07/windows10v1803/) to create and use SSH keys and make SSH connections from PowerShell or a command prompt.
@@ -52,7 +58,7 @@ The easiest way to create and manage your SSH keys is to [use the portal to crea
5258

5359
You can also create key pairs with the [Azure CLI](/cli/azure) with the [az sshkey create](/cli/azure/sshkey#az-sshkey-create) command, as described in [Generate and store SSH keys](../ssh-keys-azure-cli.md).
5460

55-
To create an SSH key pair on your local computer using the `ssh-keygen` command from PowerShell or a command prompt, type the following command:
61+
To create an SSH key pair on your local computer using the `ssh-keygen` command from PowerShell or a command prompt, use the following command:
5662

5763
```powershell
5864
ssh-keygen -m PEM -t rsa -b 2048
53.2 KB
Loading

articles/virtual-machines/ssh-keys-azure-cli.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ For more information, see [Detailed steps: Create and manage SSH keys for authen
2222

2323
For more information on how to create and use SSH keys with Linux VMs, see [Use SSH keys to connect to Linux VMs](./linux/ssh-from-windows.md).
2424

25+
> [!Note]
26+
> ED25519 SSH key support for Linux VMs is now in preview in all regions including sovereign clouds. However, Azure portal support for ED25519 is limited to Azure public cloud regions only.
27+
2528
## Generate new keys
2629

2730
1. After you sign in, use the [az sshkey create](/cli/azure/sshkey#az-sshkey-create) command to create the new SSH key:

articles/virtual-machines/ssh-keys-portal.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ You can reuse your stored keys in various of applications to fit your organizati
2525

2626
For more detailed information about creating and using SSH keys with Linux VMs, see [Use SSH keys to connect to Linux VMs](./linux/ssh-from-windows.md).
2727

28+
> [!Note]
29+
> ED25519 SSH key support for Linux VMs is now in preview in all regions including sovereign clouds. However, Azure portal support for ED25519 is limited to Azure public cloud regions only.
30+
2831
## Generate new keys
2932

3033
1. Open the [Azure portal](https://portal.azure.com).
@@ -33,7 +36,7 @@ For more detailed information about creating and using SSH keys with Linux VMs,
3336

3437
1. On the **SSH Key** page, select **Create**.
3538

36-
:::image type="content" source="./media/ssh-keys/portal-sshkey.png" alt-text="Create a new resource group and generate an SSH key pair":::
39+
:::image type="content" source="./media/ssh-keys/portal-ed25519-key.png" alt-text="Create a new resource group and generate an SSH key pair":::
3740

3841
1. In **Resource group** select **Create new** to create a new resource group to store your keys. Type a name for your resource group and select **OK**.
3942

@@ -43,6 +46,8 @@ For more detailed information about creating and using SSH keys with Linux VMs,
4346

4447
1. In **SSH public key source**, select **Generate public key source**.
4548

49+
1. In **SSH Key Type**, select either **RSA SSH Format** or **Ed25519 SSH Format** [Preview]
50+
4651
1. When you're done, select **Review + create**.
4752

4853
1. After it passes validation, select **Create**.

0 commit comments

Comments
 (0)