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.
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 the
Configure 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.
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 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:
Selectfrom the main menu.
With the Navigation bar visible ( ), choose from the run/debug configuration selector.
Press Ctrl+Shift+Alt+R, then press 0 or select the configuration from the popup and press F4.
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.
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.
Selectfrom 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]/WebApplicationto go to the application root folder.
chmod +x ./WebApplicationto add the executable bit if needed.
ASPNETCORE_URLS=http://0.0.0.0:5000 ./WebApplicationto 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
Selectfrom 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]:5000and 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: