Skip to content

Commit 6c2c56e

Browse files
author
Vamsi Kavuru
committed
update-linux-docs-ed25519
1 parent 8250df9 commit 6c2c56e

File tree

7 files changed

+120
-11
lines changed

7 files changed

+120
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ If you're having trouble connecting, you can also use portal:
6161
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.
6262

6363
> [!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.
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 or ED25519 format.
6565
6666
## [WSL, macOS, or native Linux client](#tab/Linux)
6767

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

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ The following `ssh-keygen` command generates 4096-bit SSH RSA public and private
4848
ssh-keygen -m PEM -t rsa -b 4096
4949
```
5050

51+
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.
52+
53+
```bash
54+
ssh-keygen -m PEM -t ed25519
55+
```
56+
5157
### Detailed example
5258
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.
5359

@@ -57,10 +63,19 @@ ssh-keygen \
5763
-t rsa \
5864
-b 4096 \
5965
-C "azureuser@myserver" \
60-
-f ~/.ssh/mykeys/myprivatekey \
66+
-f ~/.ssh/mykeys/myrsaprivatekey \
6167
-N mypassphrase
6268
```
69+
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.
6370

71+
```bash
72+
ssh-keygen \
73+
-m PEM \
74+
-t ed25519 \
75+
-C "azureuser@myserver" \
76+
-f ~/.ssh/mykeys/myedprivatekey \
77+
-N mypassphrase
78+
```
6479
**Command explained**
6580

6681
`ssh-keygen` = the program used to create the keys
@@ -77,7 +92,7 @@ ssh-keygen \
7792

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

80-
### Example of ssh-keygen
95+
### Example of ssh-keygen (RSA)
8196

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

106146
#### Saved key files
107147

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

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`.
150+
or
151+
152+
`Enter file in which to save the key (/home/azureuser/.ssh/id_ed25519): ~/.ssh/id_ed25519`
153+
154+
155+
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`.
111156

112157
#### List of the `~/.ssh` directory
113158

114159
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.
115160

161+
RSA Key pair:
116162
```bash
117163
ls -al ~/.ssh
118164
-rw------- 1 azureuser staff 1675 Aug 25 18:04 id_rsa
119165
-rw-r--r-- 1 azureuser staff 410 Aug 25 18:04 id_rsa.pub
120166
```
121167

168+
ED25519 Key pair:
169+
```bash
170+
ls -al ~/.ssh
171+
-rw------- 1 azureuser staff 1675 Aug 25 18:04 id_ed25519
172+
-rw-r--r-- 1 azureuser staff 410 Aug 25 18:04 id_ed25519.pub
173+
```
174+
122175
#### Key passphrase
123176

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

130183
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.
131184

185+
> [!NOTE]
186+
> [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.
187+
132188
## Provide SSH public key when deploying a VM
133189

134190
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.
135191

136192
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:
137193

194+
# RSA key pair
138195
```bash
139196
cat ~/.ssh/id_rsa.pub
140197
```
@@ -158,6 +215,30 @@ ssh-keygen \
158215
-m RFC4716 > ~/.ssh/id_ssh2.pem
159216
```
160217

218+
# ED25519 key pair
219+
```bash
220+
cat ~/.ssh/id_ed25519.pub
221+
```
222+
223+
Output is similar to the following (redacted example below):
224+
225+
```
226+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP6I5JuhGq3RidMNpxrplIQwEfc4Rh7UyV8JYYH2U2xA azureuser@myserver
227+
```
228+
229+
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`).
230+
231+
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.
232+
233+
To create a PEM formatted key from an existing SSH public key:
234+
235+
```bash
236+
ssh-keygen \
237+
-f ~/.ssh/id_ed25519.pub \
238+
-e \
239+
-m RFC4716 > ~/.ssh/id_edssh.pem
240+
```
241+
161242
## SSH to your VM with an SSH client
162243
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):
163244

@@ -184,6 +265,11 @@ Now add the private key to `ssh-agent` using the command `ssh-add`.
184265
```bash
185266
ssh-add ~/.ssh/id_rsa
186267
```
268+
or
269+
270+
```bash
271+
ssh-add ~/.ssh/id_ed25519
272+
```
187273

188274
The private key passphrase is now stored in `ssh-agent`.
189275

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ Use the `ssh-keygen` command to generate SSH public and private key files. By de
3535
The following command creates an SSH key pair using RSA encryption and a bit length of 4096:
3636

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

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

56+
> [!NOTE]
57+
> [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.
58+
5059
## Provide an SSH public key when deploying a VM
5160

5261
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 +66,28 @@ To create a Linux VM that uses SSH keys for authentication, specify your SSH pub
5766

5867
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:
5968

69+
# RSA key pair
6070
```bash
6171
cat ~/.ssh/id_rsa.pub
6272
```
63-
64-
A typical public key value looks like this example:
73+
A typical RSA public key value looks like this example:
6574

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

7088
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`.
7189

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:
90+
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:
7391

7492
```azurecli-interactive
7593
az vm create \

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Your public key can be shared with anyone, but only you (or your local security
3838

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

41+
> [!NOTE]
42+
> During preview, Ed25519 keys can only be used with Linux VMs, we intend to extend the ED25519 support to Windows VMs soon.
43+
4144
## SSH clients
4245

4346
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 +55,7 @@ The easiest way to create and manage your SSH keys is to [use the portal to crea
5255

5356
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).
5457

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:
58+
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:
5659

5760
```powershell
5861
ssh-keygen -m PEM -t rsa -b 2048
53.2 KB
Loading

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ For more detailed information about creating and using SSH keys with Linux VMs,
3333

3434
1. On the **SSH Key** page, select **Create**.
3535

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

3838
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**.
3939

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

4444
1. In **SSH public key source**, select **Generate public key source**.
4545

46+
1. In **SSH Key Type**, select either **RSA SSH Format** or **Ed25519 SSH Format** [Preview]
47+
4648
1. When you're done, select **Review + create**.
4749

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

includes/virtual-machines-common-ssh-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ ms.author: jushiman
1212

1313
## Supported SSH key formats
1414

15-
Azure currently supports SSH protocol 2 (SSH-2) RSA public-private key pairs with a minimum length of 2048 bits. Other key formats such as ED25519 and ECDSA are not supported.
15+
Azure currently supports SSH protocol 2 (SSH-2) RSA public-private key pairs with a minimum length of 2048 bits. Support for ED25519 Keys is in preview, other key formats such as ECDH and ECDSA are currenlty not supported.

0 commit comments

Comments
 (0)