Skip to main content

Runme for VS Code SSH & Remote

Runme badget

Runme enables you to execute codes and commands inside your Markdown file without switching tabs. It integrates easily with VS Code SSH and allows users to connect to remote instances effortlessly. This integration allows for easy execution of specific instructions directly in Markdown files, streamlining workflows and boosting productivity.

In this section, we will explore the various ways you can utilize Runme with VS Code SSH.

To follow up on the instructions on this page, ensure you have installed Runme on your VS Code or CLI. Also, ensure you have access to the remote server you need.

VS Code Remote Development

Runme leverages the Remote Development extension provided by VS Code to enable you to attach remote SSH hosts to your local VS Code environment. This makes task execution easier and enhances productivity by simplifying development processes, minimizing the need for manual commands, and automating repetitive tasks, saving time and reducing the likelihood of errors.

This approach also optimizes performance by ensuring consistent and reliable script and process execution, thus improving the development workflow.

💡 Note: Runme harnesses VS Code's Remote Development extensions to attach VS Code to remote SSH hosts.

How to Set up SSH Connection in VS Code

To set up your SSH key configuration, follow the steps below:

  1. Generate an SSH key if you haven't already.
  2. Identify the remote host you want to connect to and make sure you have the necessary login credentials.
  3. Ensure that you have Visual Studio Code installed on your local machine.
  4. Install the Runme extension in Visual Studio Code.
  5. Use the Visual Studio Code Remote - SSH extension to connect to the remote host via SSH.
  1. Install the Runme extension on the remote server and leverage the notebook UX to execute what you want.
  1. Create a block of code called command to execute the desired actions on the remote host.

Example: how to use Runme attached to SSH host

mkdir Vsc
cd Vsc
touch example.txt

ssh with Vsc

Key-Based Authentication

To enhance security when using Runme, it is recommended that SSH keys be used for authentication. This eliminates the need for password transmission and reduces the risk of brute-force attacks.

To execute commands on a remote server using Runme, follow these steps:

  1. Set up your SSH key configuration

Set up your SSH key configuration by following the instructions here.

  1. Set Up the Remote Server

Ensure you can access the remote server and the necessary permissions to execute commands.

  1. Create a Markdown File

Create a .md file to connect to the remote server and execute the desired commands.

  1. Create a Block of Code

In the .md file, create a block of code that uses the SSH command to connect to the remote server and execute the desired command.

ssh user@remote.server.com 'bash -s' < script.sh

This command will run a bash script called script.sh on the remote server. Make sure to replace user and remote.server.com with your own username and the server's hostname or IP address.

By following these steps and using SSH keys for authentication, you can enhance the security of your Runme commands and reduce the risk of unauthorized access or attacks.

  1. Execute the Runme command

To execute your command, run the command below

# short for "runme tui" is
runme
  1. Running Multiple Markdown files

Select the Markdown file .md you want to execute (if you have multiple .md files or different codeblocks and instruction in a .md)

runme

How to SSH into Remote Hosts From a Notebook

If you need to securely copy files from your local machine to a remote server, you can install Secure Copy Files SCP on your machine. SCP encrypts data during transmission, protecting it from unauthorized access.

To do this, you need to set up an SSH Connection and run the code below in your Markdown file

scp /path/to/bash/script user@host:/path/on/remote/server
ssh user@host 'bash /path/on/remote/server/script.sh'

This is an example of running bash script in a server.

Bash