Skip to content

Instantly share code, notes, and snippets.

@theowoo
Last active September 23, 2016 09:20
Show Gist options
  • Save theowoo/71526b99152d4689f9bdc12e7d9e5891 to your computer and use it in GitHub Desktop.
Save theowoo/71526b99152d4689f9bdc12e7d9e5891 to your computer and use it in GitHub Desktop.
Setting up ipyparallel for using the linux clusters via ssh for jupyter

Open a terminal that supports SSH (e.g. Git Bash). Check that login is successful:

ssh <user>@<ip of remote machine>

You should get prompted for passwword.

Password-less SSH

SSH alias

Create alias for ssh host by adding the following lines to <USERPROFILE>\.ssh\config (create this file without file extention if it doesn't exist)

Host <alias>
    HostName <ip of remote machine>
    Port 22
    User <user>

Now you can ssh using

ssh <alias>

authorisation

To set up for passwwordless login, first, generate a key for your local machine:

ssh-keygen -t dsa

The make a .ssh folder at the remote machine, if it doesn't exist:

ssh <alias>
mkdir .ssh
ls -a    # List all, check that ~/.ssh/ has been created.

Then copy the public key to the remote machine:

scp <USERPROFILE>\.ssh\id_rsa.pub <alias>:.ssh

SSH tunneling

Edit <USERPROFILE>\.ssh\config:

Host <alias>
    HostName <ip of remote machine>
    Port 22
    LocalForward 8000 127.0.0.1:8888    # 8888 is the default port for the first Jupyter notebook instance
    User <user>

Keep Jupyter Notebook running at remote after disconnection

Login via SSH, start the screen process, then Jupyter Notebook:

ssh <alias>
screen
cd <working dir>
jupyter notebook

You should now be able to access the Jupyter Notebook on the remote machine from your local browser at http://localhost:8000/.

Before logging out from SSH, save all unsaved input cells, then use the key combination Ctrl+A, quickly followed by D, to detach from the screen. After logging out, the tunnel http://localhost:8000/ is blocked, but will be recovered when you log in again. Any output generated while you are away will not be recoverable, but you can recall environmental outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment