Skip to content

Commit 0d44bcf

Browse files
committed
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs-pr (branch live)
2 parents bb63f8c + 3ae8025 commit 0d44bcf

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

docs/linux/connect-to-your-remote-linux-computer.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Connect to your target Linux system in Visual Studio"
33
description: "How to connect to a remote Linux machine or WSL from inside a Visual Studio C++ project."
4-
ms.date: "06/11/2019"
4+
ms.date: "06/19/2019"
55
ms.assetid: 5eeaa683-4e63-4c46-99ef-2d5f294040d4
66
---
77

@@ -15,11 +15,11 @@ Linux support is available in Visual Studio 2017 and later.
1515

1616
::: moniker range=">=vs-2017"
1717

18-
You can configure a Linux project to target a remote machine or to Windows Subsystem for Linux (WSL).
18+
You can configure a Linux project to target a remote machine or Windows Subsystem for Linux (WSL). For remote machines, and for WSL on Visual Studio 2017, you need to set up a connection.
1919

2020
## Connect to a remote Linux computer
2121

22-
When building a C++ Linux project for a remote Linux system (VM or physical machine), Linux code is copied to your remote Linux computer and then compiled based on Visual Studio settings. (In Visual Studio 2017, use these instructions to connect to WSL also. Use **localhost** for the **Host Name**.)
22+
When building a C++ Linux project for a remote Linux system (VM or physical machine), Linux code is copied to your remote Linux computer and then compiled based on Visual Studio settings.
2323

2424
To set up this remote connection:
2525

@@ -43,14 +43,26 @@ To set up this remote connection:
4343
| **Private key file** | Private key file created for ssh connection
4444
| **Passphrase** | Passphrase used with private key selected above
4545

46+
You can use either a password or key file and passphrase for authentication. For many development scenarios, password authentication is sufficient. If you prefer to use a public/private key file, you can create a new one or [reuse an existing one](https://security.stackexchange.com/questions/10203/reusing-private-public-keys). Currently only RSA and DSA keys are supported.
47+
48+
You can create a private RSA key file by following these steps:
49+
50+
1. On the Windows machine, create the ssh key pair with `ssh-keygen -t rsa`. This will create a public key and a private key. By default the keys are placed under `C:\Users\%USERNAME%\.ssh` with names `id_rsa.pub` and `id_rsa`.
51+
52+
1. From Windows, copy the public key to the Linux machine: `scp -p C:\Users\%USERNAME%\.ssh\id_rsa.pub user@hostname`.
53+
54+
1. On the Linux system, add the key to the list of authorized keys (and ensure the file has the correct permissions): `cat ~/id_rsa.pub >> ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys`
55+
4656
1. Click the **Connect** button to attempt a connection to the remote computer.
4757

4858
If the connection succeeds, Visual Studio will begin configuring IntelliSense to use the remote headers. For more information, see [IntelliSense for headers on remote systems](configure-a-linux-project.md#remote_intellisense).
4959

50-
If the connection fails, the entry boxes which need to be changed will be outlined in red.
60+
If the connection fails, the entry boxes that need to be changed are outlined in red.
5161

5262
![Connection Manager Error](media/settings_connectionmanagererror.png)
5363

64+
If you are using key files for authentication, ensure the target machine's SSH server is running and configured properly.
65+
5466
::: moniker-end
5567

5668
::: moniker range="vs-2019"
@@ -59,12 +71,22 @@ To set up this remote connection:
5971

6072
![Remote Logging](media/remote-logging-vs2019.png)
6173

62-
Logs include connections, all commands sent to the remote machine (their text, exit code and execution time), and all writes from Visual Studio to the shell. Logging works for any cross-platform CMake project or MSBuild-based Linux project in Visual Studio.
74+
Logs include connections, all commands sent to the remote machine (their text, exit code and execution time), and all output from Visual Studio to the shell. Logging works for any cross-platform CMake project or MSBuild-based Linux project in Visual Studio.
6375

6476
You can configure the output to go to a file or to the **Cross Platform Logging** pane in the Output Window. For MSBuild-based Linux projects, commands issued to the remote machine by MSBuild are not routed to the **Output Window** because they are emitted out-of-process. Instead, they are logged to a file with the "msbuild_" prefix.
6577

78+
::: moniker-end
79+
6680
## Connect to WSL
6781

82+
::: moniker range="vs-2017"
83+
84+
In Visual Studio 2017, you connect to WSL by using the same steps as connecting to a remote Linux machine as described earlier in this article. Use **localhost** for the **Host Name**.
85+
86+
::: moniker-end
87+
88+
::: moniker range="vs-2019"
89+
6890
In Visual Studio 2019 version 16.1, it is not necessary to add a remote connection or configure SSH when targeting WSL. All that is required on the Linux system is gcc, gdb, make, rsync, and zip. Visual Studio requires rsync and zip only to extract header files on first use from your WSL instance to the Windows filesystem to use for IntelliSense. In Visual Studio 2019 version 16.1, WSL support is based on Windows version 1809. You can be running a later version of Windows, but Visual Studio does not yet take advantage of new WSL capabilities.
6991

7092
If your distro supports apt, you can install the required packages with this command:

0 commit comments

Comments
 (0)