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
title: "Connect to your target Linux system in Visual Studio"
3
-
description: "How to connect to a remote Linux machine or WSL from inside a Visual Studio C++ project."
4
-
ms.date: "09/04/2019"
3
+
description: "How to connect to a remote Linux machine or Windows Subsystem for Linux from inside a Visual Studio C++ project."
4
+
ms.date: "11/09/2019"
5
5
ms.assetid: 5eeaa683-4e63-4c46-99ef-2d5f294040d4
6
6
---
7
7
# Connect to your target Linux system in Visual Studio
@@ -18,15 +18,15 @@ You can configure a Linux project to target a remote machine or the Windows Subs
18
18
19
19
## Connect to a remote Linux computer
20
20
21
-
When building a C++ Linux project for a remote Linux system (VM or physical machine), Linux source code is copied to your remote Linux computer and then compiled based on Visual Studio settings.
21
+
When building a C++ Linux project for a remote Linux system (VM or physical machine), Linux source code is copied to your remote Linux computer. Then, it's compiled based on Visual Studio settings.
22
22
23
23
To set up this remote connection:
24
24
25
-
1. Build the project for the first time or manually create a new entry by selecting**Tools > Options** and then open the **Cross Platform > Connection Manager** node and click the **Add** button.
25
+
1. Build the project for the first time. Or, you can create a new entry manually. Select**Tools > Options**, open the **Cross Platform > Connection Manager** node, and then choose the **Add** button.
In either scenario, the **Connect to Remote System** window will be displayed.
29
+
In either scenario, the **Connect to Remote System** window is displayed.
30
30
31
31

32
32
@@ -37,30 +37,30 @@ To set up this remote connection:
37
37
| **Host Name** | Name or IP address of your target device
38
38
| **Port** | Port that the SSH service is running on, typically 22
39
39
| **User name** | User to authenticate as
40
-
| **Authentication type** | Password or Private Key are both supported
40
+
| **Authentication type** | Password and Private Key are both supported
41
41
| **Password** | Password for the entered user name
42
42
| **Private key file** | Private key file created for ssh connection
43
43
| **Passphrase** | Passphrase used with private key selected above
44
44
45
-
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.
45
+
You can use either a password or a 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.
46
46
47
47
You can create a private RSA key file by following these steps:
48
48
49
-
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 defaultthe keys are placed under `C:\Users\%USERNAME%\.ssh` with names `id_rsa.pub` and `id_rsa`.
49
+
1. On the Windows machine, create the ssh key pair with `ssh-keygen -t rsa`. The command creates a public key and a private key. By default, it places the keys under `C:\Users\%USERNAME%\.ssh`, using the names `id_rsa.pub` and `id_rsa`.
50
50
51
51
1. From Windows, copy the public key to the Linux machine: `scp -p C:\Users\%USERNAME%\.ssh\id_rsa.pub user@hostname`.
52
52
53
53
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`
54
54
55
-
1.Click the **Connect** button to attempt a connection to the remote computer.
55
+
1.Choose the **Connect** button to attempt a connection to the remote computer.
56
56
57
57
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).
58
58
59
59
If the connection fails, the entry boxes that need to be changed are outlined in red.
If you are using key files for authentication, ensure the target machine's SSH server is running and configured properly.
63
+
If you use key files for authentication, make sure the target machine's SSH server is running and configured properly.
64
64
65
65
::: moniker-end
66
66
@@ -72,51 +72,51 @@ To set up this remote connection:
72
72
73
73
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.
74
74
75
-
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.
75
+
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, MSBuild commands sent to the remote machine aren't routed to the **Output Window** because they're emitted out-of-process. Instead, they're logged to a file, with a prefix of "msbuild_".
76
76
77
77
## TCP Port Forwarding
78
78
79
79
Visual Studio's Linux support has a dependency on TCP port forwarding. **Rsync** and **gdbserver** will be affected if TCP port forwarding is disabled on your remote system.
80
80
81
-
Rsync is used by both MSBuild-based Linux projects and CMake projects to [copy headers from your remote system to Windows to be used for IntelliSense](configure-a-linux-project.md#remote_intellisense). If you're not able to enable TCP port forwarding then you can disable the automatic download of remote headers via Tools > Options > Cross Platform > Connection Manager > Remote Headers IntelliSense Manager. If the remote system you are trying to connect to does not have TCP port forwarding enabled, then you will see the following error when the download of remote headers for IntelliSense begins.
81
+
rsync is used by both MSBuild-based Linux projects and CMake projects to [copy headers from your remote system to Windows for use by IntelliSense](configure-a-linux-project.md#remote_intellisense). When you can't enable TCP port forwarding, disable the automatic download of remote headers. To disable it, use **Tools > Options > Cross Platform > Connection Manager > Remote Headers IntelliSense Manager**. If the remote system doesn't have TCP port forwarding enabled, you'll see this error when the download of remote headers for IntelliSense begins:
Rsync is also used by Visual Studio's CMake support to copy source files to the remote system. If you're not able to enable TCP port forwarding then you can use sftp as your remote copy sources method . Sftp is generally slower than rsync but does not have a dependency on TCP port forwarding. You can manage your remote copy sources method with the remoteCopySourcesMethod property in the [CMake Settings Editor](../build/cmakesettings-reference.md#additional-settings-for-cmake-linux-projects). If TCP port forwarding is disabled on your remote system then you will see an error in the CMake output window the first time rsync is invoked.
85
+
rsync is also used by Visual Studio's CMake support to copy source files to the remote system. If you can't enable TCP port forwarding, you can use sftp as your remote copy sources method. sftp is often slower than rsync, but doesn't have a dependency on TCP port forwarding. You can manage your remote copy sources method with the **remoteCopySourcesMethod** property in the [CMake Settings Editor](../build/cmakesettings-reference.md#additional-settings-for-cmake-linux-projects). If TCP port forwarding is disabled on your remote system, you'll see an error in the CMake output window the first time it invokes rsync.
Gdbserver can be used for debugging on embedded devices. If you're not able to enable TCP port forwarding then you will need to use the gdb for all remote debugging scenarios. Gdb is used by default when debugging projects on a remote system.
89
+
gdbserver can be used for debugging on embedded devices. If you can't enable TCP port forwarding, then you must use gdb for all remote debugging scenarios. gdb is used by default when debugging projects on a remote system.
90
90
91
91
::: moniker-end
92
92
93
93
## Connect to WSL
94
94
95
95
::: moniker range="vs-2017"
96
96
97
-
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**.
97
+
In Visual Studio 2017, you use the same steps to connect to WSL as you use for a remote Linux machine. Use **localhost** for the **Host Name**.
98
98
99
99
::: moniker-end
100
100
101
101
::: moniker range="vs-2019"
102
102
103
-
Visual Studio 2019 version 16.1 added native support for using C++ with the [Windows Subsystem for Linux (WSL)](/windows/wsl/about). This means that you no longer need to add a remote connection or configure SSH in order to build and debug on your local WSL installation. You can find details on [how to install WSL](/windows/wsl/install-win10) here.
103
+
Visual Studio 2019 version 16.1 added native support for using C++ with the [Windows Subsystem for Linux (WSL)](/windows/wsl/about). That means you can build and debug on your local WSL installation directly. You no longer need to add a remote connection or configure SSH. You can find details on [how to install WSL](/windows/wsl/install-win10) here.
104
104
105
-
To configure your WSL installation to work with Visual Studio you need the following tools installed: gcc or clang, gdb, make, rsync, and zip. You can install them on distros that use apt by using this command, which also installs the g++ compiler:
105
+
To configure your WSL installation to work with Visual Studio, you need the following tools installed: gcc or clang, gdb, make, rsync, and zip. You can install them on distros that use apt by using this command, which also installs the g++ compiler:
106
106
107
107
```bash
108
108
sudo apt install g++ gdb make rsync zip
109
109
```
110
110
111
111
For more information, see [Download, install, and set up the Linux workload](download-install-and-setup-the-linux-development-workload.md).
112
112
113
-
To configure your project for WSL, see [Configure a Linux project](configure-a-linux-project.md) or [Configure a Linux CMake project](cmake-linux-project.md) depending on which kind of project you have. To follow step-by-step instructions for creating a simple console application with WSL, check out this introductory blog post on [C++ with Visual Studio 2019 and the Windows Subsystem for Linux (WSL)](https://devblogs.microsoft.com/cppblog/c-with-visual-studio-2019-and-windows-subsystem-for-linux-wsl/).
113
+
To configure an MSBuild project for WSL, see [Configure a Linux project](configure-a-linux-project.md). To configure a CMake project for WSL, see [Configure a Linux CMake project](cmake-linux-project.md). To follow step-by-step instructions for creating a simple console application with WSL, check out this introductory blog post on [C++ with Visual Studio 2019 and the Windows Subsystem for Linux (WSL)](https://devblogs.microsoft.com/cppblog/c-with-visual-studio-2019-and-windows-subsystem-for-linux-wsl/).
114
114
115
115
::: moniker-end
116
116
117
117
## See Also
118
118
119
119
[Configure a Linux project](configure-a-linux-project.md)\
120
120
[Configure a Linux CMake project](cmake-linux-project.md)\
121
-
[Deploy, run and debug your Linux project](deploy-run-and-debug-your-linux-project.md)\
121
+
[Deploy, run, and debug your Linux project](deploy-run-and-debug-your-linux-project.md)\
0 commit comments