Remote Debugging using SSH - splunk/vscode-extension-splunk GitHub Wiki

Remote Debugging using SSH allows you to use Visual Studio Code locally regardless of where Splunk Enterprise is running, including public cloud providers, as long as SSH connectivity is available. No source code needs to be on your local machine since all execution happens on the remote instance.

Requirements

Local Machine:

Remote Machine:

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.

images/SSH-button.png

Choose the Remote-SSH: Connect to Host command.

images/remote-ssh_connect_host.png

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

images/SSH-creds.png

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

images/vscode-open-folder.png

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

images/open_folder2.png

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.

images/SSH_python_enable.png

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.