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
description: Securely move files to and from a Linux VM in Azure using SCP and an SSH key pair.
4
-
author: cynthn
4
+
author: mattmcinnes
5
5
ms.service: virtual-machines
6
6
ms.workload: infrastructure
7
7
ms.topic: how-to
8
-
ms.date: 07/30/2022
9
-
ms.author: cynthn
8
+
ms.date: 12/9/2022
9
+
ms.author: mattmcinnes
10
+
ms.custom: GGAL-freshness822
10
11
---
11
12
12
13
# Use SCP to move files to and from a VM
@@ -15,18 +16,18 @@ ms.author: cynthn
15
16
16
17
This article shows how to move files from your workstation up to an Azure VM, or from an Azure VM down to your workstation, using Secure Copy (SCP). Moving files between your workstation and a VM, quickly and securely, is critical for managing your Azure infrastructure.
17
18
18
-
For this article, you need a VM deployed in Azure with SSH enabled. You also need an SCP client for your local computer. It is built on top of SSH and included in the default shell of most computers.
19
+
For this article, you need a VM deployed in Azure with SSH enabled. You also need an SCP client for your local computer. It's built on top of SSH and included in the default shell of most Linux and Windows (10 and newer) installations.
19
20
20
21
21
22
## Quick commands
22
23
23
-
Copy a file up to the VM
24
+
Upload a file to the VM
24
25
25
26
```bash
26
27
scp file azureuser@azurehost:directory/targetfile
27
28
```
28
29
29
-
Copy a file down from the VM
30
+
Download a file from the VM
30
31
31
32
```bash
32
33
scp azureuser@azurehost:directory/file targetfile
@@ -38,11 +39,11 @@ As examples, we move an Azure configuration file up to a VM and pull down a log
38
39
39
40
## SSH key pair authentication
40
41
41
-
SCP uses SSH for the transport layer. SSH handles the authentication on the destination host, and it moves the file in an encrypted tunnel provided by default with SSH. For SSH authentication, usernames and passwords can be used. However, SSH public and private key authentication are recommended as a security best practice. Once SSH has authenticated the connection, SCP then begins copying the file. Using a properly configured `~/.ssh/config` and SSH public and private keys, the SCP connection can be established by just using a server name (or IP address). If you only have one SSH key, SCP looks for it in the `~/.ssh/` directory, and uses it by default to log in to the VM.
42
+
SCP uses SSH for the transport layer. SSH handles the authentication on the destination host, and it moves the file in an encrypted tunnel provided by default with SSH. For SSH authentication, usernames and passwords can be used. However, SSH public and private key authentication are recommended as a security best practice. Once SSH has authenticated the connection, SCP then begins copying the file. When you use a properly configured `~/.ssh/config` and SSH public and private keys, the SCP connection can be established by just using a server name (or IP address). If you only have one SSH key, SCP looks for it in the `~/.ssh/` directory, and uses it by default to log in to the VM.
42
43
43
44
For more information on configuring your `~/.ssh/config` and SSH public and private keys, see [Create SSH keys](./linux/mac-create-ssh-keys.md).
44
45
45
-
## SCP a file to a VM
46
+
## Upload a file to a VM
46
47
47
48
For the first example, we copy an Azure configuration file up to a VM that is used to deploy automation. Because this file contains Azure API credentials, which include secrets, security is important. The encrypted tunnel provided by SSH protects the contents of the file.
48
49
@@ -52,9 +53,9 @@ The following command copies the local *.azure/config* file to an Azure VM with
For this example, we copy a directory of log files from the VM down to your workstation. A log file may or may not contain sensitive or secret data. However, using SCP ensures the contents of the log files are encrypted. Using SCP to transfer the files is the easiest way to get the log directory and files down to your workstation while also being secure.
58
+
For this example, we copy a directory of log files from the VM down to your workstation. A log file may or may not contain sensitive or secret data. However, using SCP ensures the contents of the log files are encrypted. A log directory may contain too many relevant files to copy one at a time, so downloading the whole directory is preferred in this situation. Using SCP to transfer the files is the easiest way to get the log directory and files down to your workstation while also being secure.
58
59
59
60
The following command copies files in the */home/azureuser/logs/* directory on the Azure VM to the local /tmp directory:
60
61
@@ -66,4 +67,4 @@ The `-r` flag instructs SCP to recursively copy the files and directories from t
66
67
67
68
## Next steps
68
69
69
-
*[Manage users, SSH, and check or repair disks on Azure Linux VMs using the VMAccess Extension](./extensions/vmaccess.md)
70
+
*[Manage users, SSH, and check or repair disks on Azure Linux VMs using the 'VMAccess' Extension](/extensions/vmaccess.md)
0 commit comments