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
+48-22Lines changed: 48 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +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 Windows Subsystem for Linux from inside a Visual Studio C++ project."
4
-
ms.date: "11/09/2019"
5
-
ms.assetid: 5eeaa683-4e63-4c46-99ef-2d5f294040d4
4
+
ms.date: "01/17/2020"
6
5
---
7
6
# Connect to your target Linux system in Visual Studio
8
7
@@ -14,15 +13,46 @@ Linux support is available in Visual Studio 2017 and later.
14
13
15
14
::: moniker range=">=vs-2017"
16
15
17
-
You can configure a Linux project to target a remote machine or the Windows Subsystem for Linux (WSL). For remote machines, and for WSL on Visual Studio 2017, you need to set up a remote connection.
16
+
You can configure a Linux project to target a remote machine or the Windows Subsystem for Linux (WSL). For both remote machines and for WSL, you need to set up a remote connection in Visual Studio.
18
17
19
-
## Connect to a remote Linux computer
18
+
When using a remote connection, Visual Studio builds C++ Linux projects on the remote machine. It doesn't matter if it's a physical machine, a VM in the cloud, or WSL.
19
+
To build the project, Visual Studio copies the source code to your remote Linux computer. Then, the code gets compiled based on Visual Studio settings.
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. Then, it's compiled based on Visual Studio settings.
21
+
::: moniker-end
22
+
23
+
::: moniker range="vs-2019"
24
+
25
+
> [!NOTE]
26
+
> Visual Studio 2019 version 16.5 and later also supports secure, Federal Information Processing Standard (FIPS) 140-2 compliant cryptographic connections to Linux systems for remote development. To use a FIPS-compliant connection, follow the steps in [Set up FIPS-compliant secure remote Linux development](set-up-fips-compliant-secure-remote-development.md) instead.
27
+
28
+
::: moniker-end
29
+
30
+
::: moniker range=">=vs-2017"
31
+
32
+
## Set up the SSH server on the remote system
33
+
34
+
If ssh isn't already set up and running on your Linux system, follow these steps to install it. The examples in this article use Ubuntu 18.04 LTS with OpenSSH server version 7.6. However, the instructions should be the same for any distro using a moderately recent version of OpenSSH.
35
+
36
+
1. On the Linux system, install and start the OpenSSH server:
37
+
38
+
```bash
39
+
sudo apt install openssh-server
40
+
sudo service ssh start
41
+
```
42
+
43
+
1. If you’d like the ssh server to start automatically when the system boots, enable it using systemctl:
44
+
45
+
```bash
46
+
sudo systemctl enable ssh
47
+
```
22
48
23
-
To set up this remote connection:
49
+
## Set up the remote connection
24
50
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.
51
+
1. In Visual Studio, choose **Tools > Options** on the menu bar to open the **Options** dialog. Then select **Cross Platform > Connection Manager** to open the Connection Manager dialog.
52
+
53
+
If you haven't set up a connection in Visual Studio before, when you build your project for the first time, Visual Studio opens the Connection Manager dialog for you.
54
+
55
+
1. In the Connection Manager dialog, choose the **Add** button to add a new connection.
@@ -42,19 +72,11 @@ To set up this remote connection:
42
72
| **Private key file** | Private key file created for ssh connection
43
73
| **Passphrase** | Passphrase used with private key selected above
44
74
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
-
47
-
You can create a private RSA key file by following these steps:
48
-
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
-
51
-
1. From Windows, copy the public key to the Linux machine: `scp -p C:\Users\%USERNAME%\.ssh\id_rsa.pub user@hostname`.
52
-
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`
75
+
You can use either a password or a key file and passphrase for authentication. For many development scenarios, password authentication is sufficient, but key files are more secure. If you already have a key pair, it's possible to reuse it. Currently Visual Studio only supports RSA and DSA keys for remote connections.
54
76
55
77
1. Choose the **Connect** button to attempt a connection to the remote computer.
56
78
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).
79
+
If the connection succeeds, Visual Studio configures IntelliSense to use the remote headers. For more information, see [IntelliSense for headers on remote systems](configure-a-linux-project.md#remote_intellisense).
58
80
59
81
If the connection fails, the entry boxes that need to be changed are outlined in red.
60
82
@@ -66,17 +88,21 @@ To set up this remote connection:
66
88
67
89
::: moniker range="vs-2019"
68
90
69
-
Go to **Tools > Options > Cross Platform > Logging** to enable logging to help troubleshoot connection problems:
91
+
You can enable logging to help troubleshoot connection problems. On the menu bar, select **Tools > Options**. In the **Options** dialog, select **Cross Platform > Logging**:
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
96
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_".
97
+
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_".
98
+
99
+
::: moniker-end
100
+
101
+
::: moniker range=">=vs-2017"
76
102
77
103
## TCP Port Forwarding
78
104
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. If you're impacted by this dependency, you can upvote this [suggestion ticket](https://developercommunity.visualstudio.com/idea/840265/dont-rely-on-ssh-tcp-port-forwarding-for-c-remote.html) on Developer Community.
105
+
Visual Studio's Linux support has a dependency on TCP port forwarding. **Rsync** and **gdbserver**are affected if TCP port forwarding is disabled on your remote system. If you're impacted by this dependency, you can upvote this [suggestion ticket](https://developercommunity.visualstudio.com/idea/840265/dont-rely-on-ssh-tcp-port-forwarding-for-c-remote.html) on Developer Community.
80
106
81
107
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:
82
108
@@ -88,10 +114,10 @@ rsync is also used by Visual Studio's CMake support to copy source files to the
88
114
89
115
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
116
91
-
::: moniker-end
92
-
93
117
## Connect to WSL
94
118
119
+
::: moniker-end
120
+
95
121
::: moniker range="vs-2017"
96
122
97
123
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**.
0 commit comments