RemoteREPL.jl

Connect a REPL to a remote Julia process
Author c42f
Popularity
19 Stars
Updated Last
1 Year Ago
Started In
March 2021

RemoteREPL

Build Status

RemoteREPL allows you to connect your local julia REPL to a separate Julia process and run commands interactively.

Quick start

Connecting two Julia processes on the same machine:

  1. In process A
    julia> using RemoteREPL
    
    julia> @async serve_repl()
    ┌ Info: REPL client opened a connection
    └   peer = (ip"127.0.0.1", 0xa68e)
  2. In process B
    julia> using RemoteREPL
    
    julia> connect_repl()
    REPL mode remote_repl initialized. Press > to enter and backspace to exit.
    
    remote> x = 123
    123
  3. In process A
    julia> x
    123

Connecting Julia processes on separate machines

This is the same as above, except:

  • Ensure you have an ssh server running on your.host.example and can login normally using ssh. If you've got some particular credentials or ssh options needed for your.host, you'll probably find it convenient to set these up in your openSSH config file (~/.ssh/config on unix). For example,
    Host your.host.example
        User ubuntu
        IdentityFile ~/.ssh/some_identity
  • Call connect_repl("your.host.example") in process B

Alternatives to SSH

  1. AWS Session Manager

You can use AWS Session Manager instead of SSH to connect to remote hosts. To do this, first setup Session Manager for the EC2 instances you like. See the docs. Thereafter, install AWS CLI version 2 and then install the Session Manager plugin for AWS CLI on your local system.

Setup your AWS CLI by running aws configure on the command line. You can then connect to the RemoteREPL server on your EC2 instance with connect_repl("your-instance-id"; tunnel=:aws, region="your-instance-region"). The region argument is only required if the EC2 instance is not in the default region that your CLI was setup with.

  1. kubectl

If kubectl is configured on your local system, you can use that to connect to RemoteREPL servers on your Kubernetes cluster. Run the following snippet: connect_repl("your-pod-name"; tunnel=:k8s, namespace="your-namespace"). The namespace argument is only required if the Pod is not in the default Kubernetes namespace.

Security considerations

Note that any logged-in users on the client or server machines can execute arbitrary commands in the serve_repl() process. For this reason, you should avoid using RemoteREPL on shared infrastructure like compute clusters if you don't trust other users on the system. (In the future perhaps we can avoid this by forwarding between socket files?)

This package uses an SSH tunnel by default to forward traffic when host != Sockets.localhost, so it should be quite secure to use over an open network. If both client and server are on a secure network, it's possible to skip the tunnel to avoid setting up SSH. However, if anyone breaks into your network you'll be left with no security whatsoever.

TLDR; this package aims to provide safe defaults for single-user machines. However, do not expose the RemoteREPL port to an open network. Abitrary remote code execution is the main feature provided by this package!

Used By Packages

No packages found.