SSH Remote Debugging
In this tutorial we'll see how to use an SSH tunnel to setup a secure connection between the development machine and a remote machine to debug your web application running there.
Set up SSH server on the remote machine
Depending on the operating system that the remote machine runs, configure SSH access to it.
Install and configure OpenSSH For Windows.
Configure the SSH as described in macOS User Guide: Allow a remote computer to access your Mac.
Install and configure OpenSSH Server.
Create a web application
If you have a web application, you can go on with it. Otherwise, you can create a sample ASP .NET MVC application — choose New Solution wizard:
from the main menu and use theConfigure connections to the remote machine
The connection to the remote machine will be used by two subsystems — first, to deploy the application remotely via SFTP and second, to establish a remote debugging session via SSH.
Press Ctrl+Alt+S or choose
(Windows and Linux) or (macOS) from the menu.Go to
.Click Add Insert, choose SFTP, and specify any name that will help you identify the remote machine.
Specify the address and the access credentials for the remote machine, as well as the Root path — the path on the remote machine where the application will be deployed. Make sure that this directory exists on the remote machine. Web server URL that you will use for web browser access will be calculated automatically:
Without closing the Settings/Preferences dialog, go to
.Click Add Insert and specify the SSH access credentials for the remote machine. Often they are the same as the SFTP credentials:
Click Save to save the settings and close the dialog
Deploy the application to the remote machine
To deploy applications with JetBrains Rider, you need to create and use run configurations.
Open the Run/Debug Configuration dialog in one of the following ways:
Select
from the main menu.With the Navigation bar visible ( ), choose from the run/debug configuration selector.
Press Alt+Shift+F10, then press 0 or select the configuration from the popup and press F4.
In this dialog, click Add New Configuration Alt+Insert and choose the Publish to custom server configuration type.
Specify a name that will help you identify this configuration and make sure that the solution project that corresponds to the application is selected correctly.
In the Remote server field, select the SFTP access profile that you created in the previous steps on the page of JetBrains Rider settings Ctrl+Alt+S.
Specify other options that could differ depending on the target machine:
Click OK to save the configuration and close the dialog.
Now you will be able to publish your application to the remote machine as soon as your application is ready or each time it is modified. As we used a boilerplate project template for the web application, it is ready to be published:
When the application is deployed, we can run it on the remote machine.
Select
from the menu and then select the SFTP access profile.A new session will appear in the Terminal window. Assuming that the application root folder is WebApplication, type the following commands:
cd /[application path]/WebApplication
to go to the application root folder.chmod +x ./WebApplication
to add the executable bit if needed.ASPNETCORE_URLS=http://0.0.0.0:5000 ./WebApplication
to run the application
Debug the application on the remote machine
In your application, set a breakpoint that should be hit when accessing one of its pages. If you created a new sample project in the beginning of the tutorial, you can set a breakpoint at
HomeController.cs:28
:Select
from the menu and choose the remote host and the application:If the debugger attaches successfully, the breakpoint icon will be marked with a green check mark: .
Now when the application is running with the debugger connected to it, open the application URL in a browser
http://[remote machine name]:5000
and try to access the page where the breakpoint is set.
As soon as the application execution reaches the breakpoint, it will stop and you will be able to debug it: