Skip to content

Commit 36aed78

Browse files
Merge pull request #207998 from mgreenegit/SCP-is-cross-platform
Scp is cross platform
2 parents 4bd6693 + c1a31d6 commit 36aed78

File tree

6 files changed

+79
-75
lines changed

6 files changed

+79
-75
lines changed

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34212,6 +34212,11 @@
3421234212
"source_path_from_root": "/articles/virtual-machines/windows/winrm.md",
3421334213
"redirect_url": "/azure/virtual-machines/windows/connect-winrm",
3421434214
"redirect_document_id": false
34215+
},
34216+
{
34217+
"source_path_from_root": "/articles/virtual-machines/linux/copy-files-to-linux-vm-using-scp.md",
34218+
"redirect_url": "/azure/virtual-machines/copy-files-to-vm-using-scp",
34219+
"redirect_document_id": false
3421534220
}
3421634221
]
3421734222
}

articles/azure-video-analyzer/video-analyzer-docs/edge/detect-motion-record-video-edge-devices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ To play the MP4 clip:
227227
1. Sign in by using the credentials that were generated when you set up your Azure resources.
228228
1. At the command prompt, go to the relevant directory. The default location is /var/media. You should see the MP4 files in the directory.
229229
230-
1. Use [Secure Copy (SCP)](../../../virtual-machines/linux/copy-files-to-linux-vm-using-scp.md) to copy the files to your local machine.
230+
1. Use [Secure Copy (SCP)](../../../virtual-machines/copy-files-to-vm-using-scp.md) to copy the files to your local machine.
231231
1. Play the files by using [VLC media player](https://www.videolan.org/vlc/) or any other MP4 player.
232232
233233
## Clean up resources

articles/virtual-machines/TOC.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,8 +1380,8 @@
13801380
href: ./windows/azure-to-guest-disk-mapping.md
13811381
- name: File storage
13821382
items:
1383-
- name: Copy files to a Linux VM
1384-
href: ./linux/copy-files-to-linux-vm-using-scp.md
1383+
- name: Copy files to a VM
1384+
href: ./copy-files-to-vm-using-scp.md
13851385
- name: Find unattached disks
13861386
items:
13871387
- name: CLI
Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,69 @@
1-
---
2-
title: Use SCP to move files to and from a VM
3-
description: Securely move files to and from a Linux VM in Azure using SCP and an SSH key pair.
4-
author: cynthn
5-
ms.service: virtual-machines
6-
ms.collection: linux
7-
ms.workload: infrastructure
8-
ms.topic: how-to
9-
ms.date: 04/20/2021
10-
ms.author: cynthn
11-
---
12-
13-
# Use SCP to move files to and from a Linux VM
14-
15-
**Applies to:** :heavy_check_mark: Linux VMs :heavy_check_mark: Flexible scale sets
16-
17-
This article shows how to move files from your workstation up to an Azure Linux VM, or from an Azure Linux VM down to your workstation, using Secure Copy (SCP). Moving files between your workstation and a Linux VM, quickly and securely, is critical for managing your Azure infrastructure.
18-
19-
For this article, you need a Linux VM deployed in Azure using [SSH public and private key files](mac-create-ssh-keys.md). You also need an SCP client for your local computer. It is built on top of SSH and included in the default Bash shell of most Linux and Mac computers and PowerShell.
20-
21-
22-
## Quick commands
23-
24-
Copy a file up to the Linux VM
25-
26-
```bash
27-
scp file azureuser@azurehost:directory/targetfile
28-
```
29-
30-
Copy a file down from the Linux VM
31-
32-
```bash
33-
scp azureuser@azurehost:directory/file targetfile
34-
```
35-
36-
## Detailed walkthrough
37-
38-
As examples, we move an Azure configuration file up to a Linux VM and pull down a log file directory, both using SCP and SSH keys.
39-
40-
## SSH key pair authentication
41-
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. 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.
43-
44-
For more information on configuring your `~/.ssh/config` and SSH public and private keys, see [Create SSH keys](mac-create-ssh-keys.md).
45-
46-
## SCP a file to a Linux VM
47-
48-
For the first example, we copy an Azure configuration file up to a Linux 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.
49-
50-
The following command copies the local *.azure/config* file to an Azure VM with FQDN *myserver.eastus.cloudapp.azure.com*. If you don't have an [FQDN set](../create-fqdn.md), you can also use the IP address of the VM. The admin user name on the Azure VM is *azureuser*. The file is targeted to the */home/azureuser/* directory. Substitute your own values in this command.
51-
52-
```bash
53-
scp ~/.azure/config [email protected]:/home/azureuser/config
54-
```
55-
56-
## SCP a directory from a Linux VM
57-
58-
For this example, we copy a directory of log files from the Linux 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.
59-
60-
The following command copies files in the */home/azureuser/logs/* directory on the Azure VM to the local /tmp directory:
61-
62-
```bash
63-
scp -r [email protected]:/home/azureuser/logs/. /tmp/
64-
```
65-
66-
The `-r` flag instructs SCP to recursively copy the files and directories from the point of the directory listed in the command. Also notice that the command-line syntax is similar to a `cp` copy command.
67-
68-
## Next steps
69-
70-
* [Manage users, SSH, and check or repair disks on Azure Linux VMs using the VMAccess Extension](../extensions/vmaccess.md?toc=/azure/virtual-machines/linux/toc.json)
1+
---
2+
title: Use SCP to move files to and from a VM
3+
description: Securely move files to and from a Linux VM in Azure using SCP and an SSH key pair.
4+
author: cynthn
5+
ms.service: virtual-machines
6+
ms.workload: infrastructure
7+
ms.topic: how-to
8+
ms.date: 07/30/2022
9+
ms.author: cynthn
10+
---
11+
12+
# Use SCP to move files to and from a VM
13+
14+
**Applies to:** :heavy_check_mark: Linux VMs :heavy_check_mark: Windows VMs :heavy_check_mark: Flexible scale sets
15+
16+
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+
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+
20+
21+
## Quick commands
22+
23+
Copy a file up to the VM
24+
25+
```bash
26+
scp file azureuser@azurehost:directory/targetfile
27+
```
28+
29+
Copy a file down from the VM
30+
31+
```bash
32+
scp azureuser@azurehost:directory/file targetfile
33+
```
34+
35+
## Detailed walkthrough
36+
37+
As examples, we move an Azure configuration file up to a VM and pull down a log file directory, both using SCP.
38+
39+
## SSH key pair authentication
40+
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+
43+
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+
## SCP a file to a VM
46+
47+
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+
The following command copies the local *.azure/config* file to an Azure VM with FQDN *myserver.eastus.cloudapp.azure.com*. If you don't have an [FQDN set](/create-fqdn.md), you can also use the IP address of the VM. The admin user name on the Azure VM is *azureuser*. The file is targeted to the */home/azureuser/* directory. Substitute your own values in this command.
50+
51+
```bash
52+
scp ~/.azure/config [email protected]:/home/azureuser/config
53+
```
54+
55+
## SCP a directory from a VM
56+
57+
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+
59+
The following command copies files in the */home/azureuser/logs/* directory on the Azure VM to the local /tmp directory:
60+
61+
```bash
62+
scp -r [email protected]:/home/azureuser/logs/. /tmp/
63+
```
64+
65+
The `-r` flag instructs SCP to recursively copy the files and directories from the point of the directory listed in the command. Also notice that the command-line syntax is similar to a `cp` copy command.
66+
67+
## Next steps
68+
69+
* [Manage users, SSH, and check or repair disks on Azure Linux VMs using the VMAccess Extension](/extensions/vmaccess.md?toc=/azure/virtual-machines/linux/toc.json)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ Once the above prerequisites are met, you are ready to connect to your VM. Open
178178
179179
## Next steps
180180
181-
Learn how to transfer files to an existing Linux VM, see [Use SCP to move files to and from a Linux VM](./linux/copy-files-to-linux-vm-using-scp.md).
181+
Learn how to transfer files to an existing VM, see [Use SCP to move files to and from a VM](./copy-files-to-vm-using-scp.md).

articles/virtual-machines/windows/connect-ssh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,4 @@ az ssh vm -g $myResourceGroup -n $myVM --local-user $myUsername -- -L 3389:loca
287287

288288

289289
## Next steps
290-
Learn how to transfer files to an existing VM, see [Use SCP to move files to and from a Linux VM](../linux/copy-files-to-linux-vm-using-scp.md). The same steps will also work for Windows machines.
290+
Learn how to transfer files to an existing VM, see [Use SCP to move files to and from a VM](../copy-files-to-vm-using-scp.md).

0 commit comments

Comments
 (0)