Skip to content

Debugging Remote Container

Jason Conger edited this page Aug 2, 2022 · 1 revision

Remote Container Debugging allows you to use Visual Studio Code locally to debug code running in a container. No source code needs to be on your local machine since all execution happens on the remote instance.

Requirements

Local Machine:

Remote Container:

Walkthrough

Step 1 – Set up SSH

Remote access to a machine can be accomplished using a username and password or an SSH public/private key pair. Key-based authentication should improve security.

If you do not have an SSH key pair, open a bash shell or command line and run the following command to generate one:

ssh-keygen -t rsa -b 2048

You must add the SSH key to your remote SSH host. This process depends upon your SSH host and is not covered in this walkthrough.

Step 2 – Connect to the remote Splunk Enterprise instance from Visual Studio Code

The Remote SSH extension is installed by the Visual Studio Code Extension for Splunk. It adds an indicator to the bottom-left corner of the Status Bar in Visual Studio Code, indicating the context in which Visual Studio Code is running (local or remote). Click this indicator to bring up a list of Remote Extension commands.

Choose the Remote-SSH: Connect to Host command.

Specify the username@hostname where username is associated with the SSH key, and hostname is the remote Splunk instance.

A new instance of Visual Studio Code will open, connected to the remote Splunk instance.

Step 3 – Open the root folder of your Splunk app

Choose Open folder...

Type in the path to your Splunk app location and click OK.

Step 4 – Enable the Python Extension in SSH

By default, the Python extension is not enabled for SSH. Click the Extensions button (1) in the Activity bar on the left, then click the Install in SSH button (2) for the Python extension.

You can now debug using the same techniques as if you were connected locally.

Troubleshooting

Ensure your SSH credentials have read permissions to necessary files.