JetBrains Rider 2020.3 Help

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 File | New from the main menu and use the New Solution wizard:

Creating a new ASP.NET MVC application

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.

  1. Press Ctrl+Alt+S or choose File | Settings (Windows and Linux) or JetBrains Rider | Preferences (macOS) from the menu.

  2. Go to Build, Execution, Deployment | Deployment.

  3. Click Add Add Insert, choose SFTP, and specify any name that will help you identify the remote machine.

  4. 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:

    SSH remote debugging. Deployment settings
  5. Without closing the Settings/Preferences dialog, go to Build, Execution, Deployment | Debugger | Remote Debug.

  6. Click Add Add Insert and specify the SSH access credentials for the remote machine. In most cases, they are the same as the SFTP credentials:

    SSH remote debugging. Remote debug settings
  7. 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.

  1. Open the Run/Debug Configuration dialog in one of the following ways:

    • Select Run | Edit Configurations from the main menu.

    • With the Navigation bar visible (View | Appearance | Navigation Bar ), choose Edit Configurations from the run/debug configuration selector.

    • Press Alt+Shift+F10, then press 0 or select the configuration from the popup and press F4.

  2. In this dialog, click Add New Configuration Add New Configuration Alt+Insert and choose the Publish to custom server configuration type.

  3. 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.

  4. In the Remote server field, select the SFTP access profile that you created in the previous steps on the Build, Execution, Deployment | Deployment page of JetBrains Rider settings Ctrl+Alt+S.

  5. Specify other options that could differ depending on the target machine:

    SSH remote debugging. Deployment configuration
  6. 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:

SSH remote debugging. Deployment run

When the application is deployed, we can run it on the remote machine.

  1. Select Tools | Start SSH session from the menu and then select the SFTP access profile.

    SSH remote debugging. Start SSH session
  2. 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

    SSH remote debugging. Terminal

Debug the application on the remote machine

  1. 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:

    SSH remote debugging. Breakpoint
  2. Select Run | Attach to Remote Process from the menu and choose the remote host and the application:

    SSH remote debugging. Attach

    If the debugger attaches successfully, the breakpoint icon will be marked with a green check mark: Breakpoint valid.

  3. 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.

    SSH remote debugging. Opening the application in the browser

As soon as the application execution reaches the breakpoint, it will stop and you will be able to debug it:

SSH remote debugging. Debugging the application
Last modified: 08 March 2021