SSH and Jupyter Notebook remotely

Lingling Yang
2 min readSep 17, 2019

1. SSH Directly

$ ssh your_username@host_ip_address
  • checking the ip address in Ubuntu
$ ip addr show

It shows ipv4 and ipv6:

2. SSH Using ngrok

Server Side

  1. Installation

2. Launch Service

$ ./ngrok tcp 22

Client Side

  1. SSH to the server
# xxxx: user name, -p12345: possword
$ ssh xxxx@0.tcp.ngrok.io -p12345

3. Launch jupyter notebook Method

  1. Open jupyter notebook in the server

Method1: open the jupyter notebook in the server directly.

$ jupyter notebook

Method2. open the jupyter notebook in the server through SSH

# SSH to the server 
(local)$ ssh xxxx@0.tcp.ngrok.io -p12345
# type screen and jupyter notebook
(server)$ screen
(server)$ jupyter notebook

2. mount the server web address (8888) to local (i.e 8008)

$ ssh -L 8008:localhost:8888 xxxx@0.tcp.ngrok.io -p 12345

The terminal show web address, starting with:
http://localhost:xxxx (following 8810)

  • Check currently running jupyter notebook servers
$ jupyter notebook list
  • Stop a running notebook
# jupyter notebook stop 8889

3. Open the remote jupyter notebook locally in web browser using http://localhost:8008

4. Screen Usage

Screen is a terminal multiplexer. You can start a screen session and then open any number of windows (virtual terminals) inside the session. Processes running in Screen will continue to run when their window is not visible even if you get disconnected.

(1) To start a screen session

$ screen# start named session
$ screen -S session_name

(2) List the current running screen sessions

$ screen -ls

(3) Detach from and reattach to a Linux Screen Window

Ctrl+a d Detach from screen window

Ctrl+a k Kill the screen.

To resume your screen session

$ screen -r# in case having multiply screen windows, resume screen 24430.pts
$ screen -r 24430

(4) Working with Linux Screen Windows

When you create a new screen session, it creates a single window with a shell in it. You can have multiple windows inside a screen session.

The most common commands for managing Linux Screen Windows:

  • Ctrl+a c Create a new window (with shell)
  • Ctrl+a " List all windows
  • Ctrl+a 0 Switch to window 0 (by number)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response