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
+20-11Lines changed: 20 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -19,20 +19,10 @@ You can configure a Linux project to target a remote machine or to Windows Subsy
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
26
-
1. Create a private key file (or [reuse an existing one](https://security.stackexchange.com/questions/10203/reusing-private-public-keys)). Currently only RSA and DSA keys are supported. You can create a private RSA key file by following these steps:
27
-
28
-
1. On the Windows machine, create the ssh key pair with `ssh-keygen -t rsa`
29
-
30
-
1. From Windows, copy the public key to the Linux machine: `scp -p C:\Users\<USERNAME>\.ssh\id_rsa.pub user@hostname`:
31
-
32
-
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`
33
-
34
-
1. In Visual Studio, add the connection (in Connection Manager). The default private key name is `C:\Users\<USERNAME>\.ssh\id_rsa`.
35
-
36
26
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.
@@ -53,7 +43,16 @@ To set up this remote connection:
53
43
| **Private key file** | Private key file created for ssh connection
54
44
| **Passphrase** | Passphrase used with private key selected above
55
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.
56
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
+
57
56
1. Click the **Connect** button to attempt a connection to the remote computer.
58
57
59
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).
@@ -62,6 +61,8 @@ To set up this remote connection:
If you are using key files for authentication, ensure the target machine's SSH server is running and configured properly.
65
+
65
66
::: moniker-end
66
67
67
68
::: moniker range="vs-2019"
@@ -76,6 +77,14 @@ To set up this remote connection:
76
77
77
78
## Connect to WSL
78
79
80
+
::: moniker range="vs-2017"
81
+
82
+
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**.
83
+
84
+
::: moniker-end
85
+
86
+
::: moniker range="vs-2019"
87
+
79
88
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.
80
89
81
90
If your distro supports apt, you can install the required packages with this command:
0 commit comments