You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux-vm-connect.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,9 @@ When hosting a Linux virtual machine on Azure, the most common method for access
16
16
17
17
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).
18
18
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
+
19
22
## Prerequisites
20
23
21
24
- 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:
61
64
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.
62
65
63
66
> [!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.
65
68
66
69
## [WSL, macOS, or native Linux client](#tab/Linux)
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.
19
19
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).
21
21
22
22
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.
23
23
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.
@@ -48,6 +51,12 @@ The following `ssh-keygen` command generates 4096-bit SSH RSA public and private
48
51
ssh-keygen -m PEM -t rsa -b 4096
49
52
```
50
53
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
+
51
60
### Detailed example
52
61
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.
53
62
@@ -57,10 +66,19 @@ ssh-keygen \
57
66
-t rsa \
58
67
-b 4096 \
59
68
-C "azureuser@myserver" \
60
-
-f ~/.ssh/mykeys/myprivatekey \
69
+
-f ~/.ssh/mykeys/myrsaprivatekey \
61
70
-N mypassphrase
62
71
```
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.
63
73
74
+
```bash
75
+
ssh-keygen \
76
+
-m PEM \
77
+
-t ed25519 \
78
+
-C "azureuser@myserver" \
79
+
-f ~/.ssh/mykeys/myedprivatekey \
80
+
-N mypassphrase
81
+
```
64
82
**Command explained**
65
83
66
84
`ssh-keygen` = the program used to create the keys
@@ -77,7 +95,7 @@ ssh-keygen \
77
95
78
96
`-N mypassphrase` = an additional passphrase used to access the private key file.
`Enter file in which to save the key (/home/azureuser/.ssh/id_rsa): ~/.ssh/id_rsa`
109
152
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`.
111
159
112
160
#### List of the `~/.ssh` directory
113
161
114
162
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.
115
163
164
+
RSA Key pair:
116
165
```bash
117
166
ls -al ~/.ssh
118
167
-rw------- 1 azureuser staff 1675 Aug 25 18:04 id_rsa
119
168
-rw-r--r-- 1 azureuser staff 410 Aug 25 18:04 id_rsa.pub
120
169
```
121
170
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
+
122
178
#### Key passphrase
123
179
124
180
`Enter passphrase (empty for no passphrase):`
@@ -129,12 +185,16 @@ It is *strongly* recommended to add a passphrase to your private key. Without a
129
185
130
186
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.
131
187
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
+
132
191
## Provide SSH public key when deploying a VM
133
192
134
193
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.
135
194
136
195
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:
137
196
197
+
### RSA key pair
138
198
```bash
139
199
cat ~/.ssh/id_rsa.pub
140
200
```
@@ -149,7 +209,7 @@ If you copy and paste the contents of the public key file into the Azure portal
149
209
150
210
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.
151
211
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:
153
213
154
214
```bash
155
215
ssh-keygen \
@@ -158,6 +218,30 @@ ssh-keygen \
158
218
-m RFC4716 >~/.ssh/id_ssh2.pem
159
219
```
160
220
221
+
### ED25519 key pair
222
+
```bash
223
+
cat ~/.ssh/id_ed25519.pub
224
+
```
225
+
226
+
Output is similar to the following (redacted example below):
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
+
161
245
## SSH to your VM with an SSH client
162
246
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):
163
247
@@ -184,6 +268,11 @@ Now add the private key to `ssh-agent` using the command `ssh-add`.
184
268
```bash
185
269
ssh-add ~/.ssh/id_rsa
186
270
```
271
+
or
272
+
273
+
```bash
274
+
ssh-add ~/.ssh/id_ed25519
275
+
```
187
276
188
277
The private key passphrase is now stored in `ssh-agent`.
> 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
+
31
34
## Create an SSH key pair
32
35
33
36
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.
34
37
35
38
The following command creates an SSH key pair using RSA encryption and a bit length of 4096:
@@ -47,6 +56,9 @@ If you use the [Azure CLI](/cli/azure) to create your VM with the [az vm create]
47
56
az vm create --name VMname --resource-group RGname --image Ubuntu2204 --generate-ssh-keys
48
57
```
49
58
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
+
50
62
## Provide an SSH public key when deploying a VM
51
63
52
64
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
57
69
58
70
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:
59
71
72
+
### RSA key pair
60
73
```bash
61
74
cat ~/.ssh/id_rsa.pub
62
75
```
63
-
64
-
A typical public key value looks like this example:
76
+
A typical RSA public key value looks like this example:
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`.
71
92
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:
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/ssh-from-windows.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,9 @@ This article is for Windows users who want to [create](#create-an-ssh-key-pair)
20
20
21
21
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).
22
22
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
+
23
26
## Overview of SSH and keys
24
27
25
28
[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
> During preview, ED25519 keys can only be used with Linux VMs.
46
+
41
47
## SSH clients
42
48
43
49
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
52
58
53
59
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).
54
60
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:
Copy file name to clipboardExpand all lines: articles/virtual-machines/ssh-keys-azure-cli.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,9 @@ For more information, see [Detailed steps: Create and manage SSH keys for authen
22
22
23
23
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).
24
24
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
+
25
28
## Generate new keys
26
29
27
30
1. After you sign in, use the [az sshkey create](/cli/azure/sshkey#az-sshkey-create) command to create the new SSH key:
Copy file name to clipboardExpand all lines: articles/virtual-machines/ssh-keys-portal.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,9 @@ You can reuse your stored keys in various of applications to fit your organizati
25
25
26
26
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).
27
27
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
+
28
31
## Generate new keys
29
32
30
33
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,
33
36
34
37
1. On the **SSH Key** page, select **Create**.
35
38
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":::
37
40
38
41
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**.
39
42
@@ -43,6 +46,8 @@ For more detailed information about creating and using SSH keys with Linux VMs,
43
46
44
47
1. In **SSH public key source**, select **Generate public key source**.
45
48
49
+
1. In **SSH Key Type**, select either **RSA SSH Format** or **Ed25519 SSH Format**[Preview]
0 commit comments