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: docs/linux/connect-to-your-remote-linux-computer.md
+27-5Lines changed: 27 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Connect to your target Linux system in Visual Studio"
3
3
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"
5
5
ms.assetid: 5eeaa683-4e63-4c46-99ef-2d5f294040d4
6
6
---
7
7
@@ -15,11 +15,11 @@ Linux support is available in Visual Studio 2017 and later.
15
15
16
16
::: moniker range=">=vs-2017"
17
17
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.
19
19
20
20
## Connect to a remote Linux computer
21
21
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.
23
23
24
24
To set up this remote connection:
25
25
@@ -43,14 +43,26 @@ To set up this remote connection:
43
43
| **Private key file** | Private key file created for ssh connection
44
44
| **Passphrase** | Passphrase used with private key selected above
45
45
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
+
46
56
1. Click the **Connect** button to attempt a connection to the remote computer.
47
57
48
58
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).
49
59
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.
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.
63
75
64
76
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.
65
77
78
+
::: moniker-end
79
+
66
80
## Connect to WSL
67
81
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
+
68
90
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.
69
91
70
92
If your distro supports apt, you can install the required packages with this command:
0 commit comments