Skip to content

Commit b3c8c57

Browse files
Merge pull request #5843 from cdpark/refresh-vs-articles-4
Feature 363608: Q&M: Content Freshness for C++ Content -- batch 4
2 parents a2bce3a + db98bc9 commit b3c8c57

3 files changed

+133
-125
lines changed

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

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: "Connect to your target Linux system in Visual Studio"
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: 03/14/2022
2+
title: "Connect to a Target Linux System by Using Visual Studio"
3+
description: "Learn how to connect to a remote Linux machine or Windows Subsystem for Linux from inside a Visual Studio C++ project."
4+
ms.topic: tutorial
5+
ms.date: 03/21/2025
56
---
6-
# Connect to your target Linux system in Visual Studio
7+
# Connect to your remote Linux system by using Visual Studio
78

89
::: moniker range="msvc-140"
910

@@ -26,6 +27,7 @@ You can configure a Linux project to target a remote machine or the Windows Subs
2627
::: moniker range=">=msvc-150"
2728

2829
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 virtual machine in the cloud, or WSL.
30+
2931
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.
3032

3133
::: moniker-end
@@ -39,7 +41,7 @@ To build the project, Visual Studio copies the source code to your remote Linux
3941

4042
::: moniker range=">=msvc-150"
4143

42-
## Set up the SSH server on the remote system
44+
## Set up the SSH server on the remote machine
4345

4446
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.
4547

@@ -58,7 +60,7 @@ If `ssh` isn't already set up and running on your Linux system, follow these ste
5860

5961
## Set up the remote connection
6062

61-
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.
63+
1. In Visual Studio on your local Windows system, choose **Tools > Options** on the menu bar to open the **Options** dialog. Then select **Cross Platform > Connection Manager** to open the Connection Manager dialog.
6264

6365
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.
6466

@@ -69,11 +71,11 @@ If `ssh` isn't already set up and running on your Linux system, follow these ste
6971
:::image-end:::
7072

7173
To edit an existing connection, choose **Edit**. In either scenario, the **Connect to Remote System** window is displayed.
72-
74+
7375
:::image type="complex" source="media/connect-to-your-remote-linux-computer/connect-updated.png" alt-text="Screenshot of the Visual Studio Connect to Remote System window.":::
7476
In the Connect to Remote System window, there are fields for host name, port, user name, authentication type, and password. Port is set to 22. Authentication type is set to 'Password'.
7577
:::image-end:::
76-
78+
7779
1. Enter the following information:
7880

7981
| Entry | Description |
@@ -84,23 +86,23 @@ If `ssh` isn't already set up and running on your Linux system, follow these ste
8486
| **Authentication type** | Password and Private Key are both supported |
8587
| **Password** | Password for the entered user name |
8688
| **Private key file** | Private key file created for ssh connection |
87-
| **Passphrase** | Passphrase used with private key selected above |
89+
| **Passphrase** | Passphrase used with private key selected previously |
8890

89-
You can't click the **Connect** button until all the required fields are completed and the port is set to an integer between 1 and 65535.
91+
You can't select the **Connect** button until all the required fields are completed and the port is set to an integer between 1 and 65535.
9092

9193
You can use either a password or a key file and passphrase for authentication. Key files are more secure than username/password. If you already have a key pair, it's possible to reuse it.
9294

93-
Versions of Visual Studio before 17.10 support Elliptic Curve (EC), Rivert-Shamir-Adleman (RSA), and Digital signature algorithm (DSA) keys for remote connections. Because of security concerns, DSA keys are no longer supported in VS 17.10 and later. RSA keys were also not supported in VS 17.10 and VS 17.11 but some types are supported again in VS 17.12 and later. To create a key pair compatible with the connection manager you can use the command:
95+
Versions of Visual Studio before 17.10 support Elliptic Curve (EC), Rivert-Shamir-Adleman (RSA), and Digital signature algorithm (DSA) keys for remote connections. Because of security concerns, DSA keys are no longer supported in VS 17.10 and later. RSA keys were also not supported in VS 17.10 and VS 17.11 but some types are supported again in VS 17.12 and later. To create a key pair compatible with the connection manager, you can use the command:
9496
`ssh-keygen -m pem -t ecdsa -f <key-name>`
9597

9698
> [!NOTE]
97-
> If using `ssh-keygen` to create the private key, you must specify the switch `-m pem`, or the key will not be accepted by Visual Studio. If your private key begins with `-----BEGIN OPENSSH PRIVATE KEY-----`, you must convert it with `ssh-keygen -p -f <FILE> -m pem`.
99+
> If using `ssh-keygen` to create the private key, you must specify the switch `-m pem`, or the key isn't accepted by Visual Studio. If your private key begins with `-----BEGIN OPENSSH PRIVATE KEY-----`, you must convert it with `ssh-keygen -p -f <FILE> -m pem`.
98100
99101
1. Choose the **Connect** button to attempt a connection to the remote computer.
100102

101103
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).
102104

103-
If the connection fails, an info bar with error information appears and the fields that you may need to change are outlined in red.
105+
If the connection fails, an info bar with error information appears and the fields that you might need to change are outlined in red.
104106

105107
:::image type="content" source="media/connect-to-your-remote-linux-computer/settings-connection-manager-error-updated.png" alt-text="Screenshot of the Visual Studio Connect to Remote System window. The host name and port fields are outlined in red to indicate incorrect entries.":::
106108

@@ -114,13 +116,13 @@ If `ssh` isn't already set up and running on your Linux system, follow these ste
114116

115117
## Host key verification
116118

117-
In Visual Studio version 16.10 or later, you're asked to verify the server's host key fingerprint whenever Visual Studio connects to a remote system for the first time. You may be familiar with this process if you've used the OpenSSH command-line client or PuTTY before. The fingerprint identifies the server. Visual Studio uses the fingerprint to ensure it's connecting to the intended and trusted server.
119+
In Visual Studio version 16.10 or later, you're asked to verify the server's host key fingerprint whenever Visual Studio connects to a remote system for the first time. You might be familiar with this process if you've used the OpenSSH command-line client or PuTTY before. The fingerprint identifies the server. Visual Studio uses the fingerprint to ensure it connects to the intended and trusted server.
118120

119121
The first time Visual Studio establishes a new remote connection, you're asked to accept or deny the host key fingerprint presented by the server. Or, anytime there are changes to a cached fingerprint. You can also verify a fingerprint on demand: select a connection in the Connection Manager and choose **Verify**.
120122

121123
If you upgrade to Visual Studio 16.10 or later from an older version, it treats any existing remote connections as new connections. You're prompted to accept the host key fingerprint first. Then, Visual Studio establishes a connection and caches the accepted fingerprint.
122124

123-
You can also update remote connections from `ConnectionManager.exe` using the `update` argument.
125+
You can also update remote connections from *`ConnectionManager.exe`* using the `update` argument.
124126

125127
## Supported SSH algorithms
126128

@@ -137,13 +139,13 @@ Starting in Visual Studio version 16.9, support for older, insecure SSH algorith
137139

138140
First, a little background. You can't select the SSH algorithm to use from Visual Studio. Instead, the algorithm is determined during the initial handshake with the SSH server. Each side (client and server) provides a list of algorithms it supports, and then the first algorithm common to both is selected. The connection succeeds as long as there's at least one algorithm in common between Visual Studio and the server for encryption, HMAC, key exchange, and so on.
139141

140-
The Open SSH configuration file (*`sshd_config`*) doesn't configure which algorithm to use by default. The SSH server should use secure defaults when no algorithms are specified. Those defaults depend on the version and vendor of the SSH server. If Visual Studio doesn't support those defaults, you'll likely see an error like: "Could not connect to the remote system. No common client to server HMAC algorithm was found." The error may also appear if the SSH server is configured to use algorithms that Visual Studio doesn't support.
142+
The Open SSH configuration file (*`sshd_config`*) doesn't configure which algorithm to use by default. The SSH server should use secure defaults when no algorithms are specified. Those defaults depend on the version and vendor of the SSH server. If Visual Studio doesn't support those defaults, you'll likely see an error like: *Could not connect to the remote system. No common client to server HMAC algorithm was found.* The error might also appear if the SSH server is configured to use algorithms that Visual Studio doesn't support.
141143

142-
The default SSH server on most modern Linux distributions should work with Visual Studio. However, you may be running an older SSH server that's configured to use older, insecure algorithms. The following example explains how to update to more secure versions.
144+
The default SSH server on most modern Linux distributions should work with Visual Studio. However, you might be running an older SSH server that's configured to use older, insecure algorithms. The following example explains how to update to more secure versions.
143145

144-
In the following example, the SSH server uses the insecure `hmac-sha1` algorithm, which Visual Studio 16.9 doesn't support. If the SSH server uses OpenSSH, you can edit the `/etc/ssh/sshd_config` file as shown below to enable more secure algorithms. For other SSH servers, refer to the server's documentation for how to configure them.
146+
In this example, the SSH server uses the insecure `hmac-sha1` algorithm, which Visual Studio 16.9 doesn't support. If the SSH server uses OpenSSH, you can edit the `/etc/ssh/sshd_config` file to enable more secure algorithms. For other SSH servers, refer to the server's documentation for how to configure them.
145147

146-
First, verify that the set of algorithms your server is using includes algorithms supported by Visual Studio. Run the following command on the remote machine to list the algorithms supported by the server:
148+
First, verify that the set of algorithms your server is using includes algorithms supported by Visual Studio. Run the following command on the remote machine to list the algorithms supported by the server:
147149

148150
```bash
149151
ssh -Q cipher; ssh -Q mac; ssh -Q kex; ssh -Q key
@@ -169,7 +171,7 @@ These examples can be added anywhere in `/etc/ssh/sshd_config`. Ensure that they
169171

170172
After editing the file, restart the SSH server (`sudo service ssh restart` on Ubuntu) and attempt to connect again from Visual Studio.
171173

172-
#### Cipher example
174+
#### Cipher example
173175

174176
Add: `Ciphers <algorithms to enable>`
175177
For example: `Ciphers aes128-cbc,aes256-cbc`
@@ -191,25 +193,25 @@ For example: `HostKeyAlgorithms ecdsa-sha2-nistp256,ecdsa-sha2-nistp384`
191193

192194
## Logging for remote connections
193195

194-
You can enable logging to help troubleshoot connection problems. On the menu bar, select **Tools > Options**. In the **Options** dialog, select **Cross Platform > Logging**:
196+
You can enable logging to help troubleshoot connection problems. On the menu bar, select **Tools > Options**. In the **Options** dialog, select **Cross Platform > Logging**:
195197

196-
:::image type="complex" source="media/remote-logging-vs2019.png" alt-text="Screenshot of the Visual Studio options screen.":::
197-
The options are open to Cross Platform > Connection Manager > Logging. Enable logging is checked, log to a file is checked, the logfile directory is set the documents folder, and log to the 'Cross Platform Logging' pane in the output window is checked.
198-
:::image-end:::
198+
:::image type="complex" source="media/remote-logging-vs2019.png" alt-text="Screenshot of the Visual Studio options screen.":::
199+
The options are open to Cross Platform > Connection Manager > Logging. Enable logging is checked, log to a file is checked, the logfile directory is set the documents folder, and log to the 'Cross Platform Logging' pane in the output window is checked.
200+
:::image-end:::
199201

200-
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.
202+
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.
201203

202-
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_".
204+
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_`.
203205

204206
## Command-line utility for the Connection Manager
205207

206-
**Visual Studio 2019 version 16.5 or later**: `ConnectionManager.exe` is a command-line utility to manage remote development connections outside of Visual Studio. It's useful for tasks such as provisioning a new development machine. Or, you can use it to set up Visual Studio for continuous integration. For examples and a complete reference to the ConnectionManager command, see [ConnectionManager reference](connectionmanager-reference.md).
208+
**Visual Studio 2019 version 16.5 or later**: *`ConnectionManager.exe`* is a command-line utility to manage remote development connections outside of Visual Studio. It's useful for tasks such as provisioning a new development machine. Or, you can use it to set up Visual Studio for continuous integration. For examples and a complete reference to the `ConnectionManager` command, see [ConnectionManager reference](connectionmanager-reference.md).
207209

208210
::: moniker-end
209211

210212
::: moniker range=">=msvc-150"
211213

212-
## TCP Port Forwarding
214+
## TCP port forwarding
213215

214216
The `rsync` command 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, this error appears when the download of remote headers for IntelliSense begins:
215217

@@ -231,7 +233,7 @@ Visual Studio's Linux support has a dependency on TCP port forwarding. Both `rsy
231233

232234
::: moniker range="msvc-150"
233235

234-
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**.
236+
In Visual Studio 2017, you use the same steps to connect to Windows Subsystem for Linux (WSL) as you use for a remote Linux machine. Use `localhost` for the **Host Name**.
235237

236238
::: moniker-end
237239

@@ -247,7 +249,7 @@ sudo apt install g++ gdb make ninja-build rsync zip
247249

248250
### Fix WSL `localhost` connection problems
249251

250-
When connecting to Windows Subsystem for Linux (WSL) on `localhost`, you may run into a conflict with the Windows `ssh` client on port 22. In WSL, change the port that `ssh` expects requests from to 23 in `/etc/ssh/sshd_config`:
252+
When connecting to WSL on `localhost`, you might run into a conflict with the Windows `ssh` client on port 22. In WSL, change the port that `ssh` expects requests from to 23 in `/etc/ssh/sshd_config`:
251253

252254
```bash
253255
Port 23
@@ -270,9 +272,9 @@ To configure an MSBuild project for WSL, see [Configure a Linux project](configu
270272

271273
::: moniker-end
272274

273-
## See Also
275+
## See also
274276

275-
[Configure a Linux project](configure-a-linux-project.md)\
276-
[Configure a Linux CMake project](cmake-linux-project.md)\
277-
[Deploy, run, and debug your Linux project](deploy-run-and-debug-your-linux-project.md)\
278-
[Configure CMake debugging sessions](../build/configure-cmake-debugging-sessions.md)
277+
- [Configure a Linux MSBuild C++ project in Visual Studio](configure-a-linux-project.md)
278+
- [Create a CMake Linux project in Visual Studio](cmake-linux-project.md)
279+
- [Deploy, run, and debug your Linux MSBuild project](deploy-run-and-debug-your-linux-project.md)
280+
- [Configure CMake debugging sessions](../build/configure-cmake-debugging-sessions.md)

0 commit comments

Comments
 (0)