How to connect your Spyder IDE to an external ipython kernel with SSH PuTTY tunnel

Raphael Mazzine, Ph.D.
3 min readMar 2, 2019

--

Check this story on my webpage: https://rmazzine.com/2019/03/02/how-to-connect-your-spyder-ide-to-an-external-ipython-kernel-with-ssh-putty-tunnel/

This is a simple tutorial to connect your local Spyder IDE to a remote ipython kernel (for example, a server from Google Cloud).

First, you must install in both server and client sides the Spyder-Kernels package.

conda install spyder-kernels

Now you must start your kernel on the server console:

server:~$ python -m spyder_kernels.console - matplotlib=’inline’    --ip=127.0.0.1 -f=./remotemachine.json

You will generate on your current folder a JSON file named remotemachine.json, it has connection parameters from the server kernel. Notice we assigned the IP address 127.0.0.1 for the Kernel, the remotemachine.json has something like this:

We will need all those ports numbers (shell_port, iopub_port, stdin_port, control_port and hb_port) so take note of them.

Now, you must copy the JSON file to your local machine.

On the local machine, set up PuTTY to connect to your server.

If you don’t know how to configure it, here is a good video showing how to connect to Google Cloud using PuTYY: https://www.youtube.com/watch?v=PFR5os97Wsc&t=347s

After configuring the connection parameters, you now must configure the SSH tunnelling parameters (on Connection-SSH-Tunnels).

We will tunnel our local client ports to the server kernel port numbers (that you took note). Therefore, you must type the port numbers on Source Port and, in Destination we will redirect to the server kernel IP and port. Repeat the same procedure to all other ports.

Now press Open to start the tunneling.

On the client side, start the Spyder IDE, click on the Consoles and Connect to an existing kernel. Browse and select the remotemachine.json file and press OK.

It’s done! Now you are connected to an external kernel through a SSH PuTTY tunnel.

I would like to thank Haidar Almubarak as I used part of his tutorial

--

--

Responses (2)