I want to start the ipython notebook server on a machine on the network and use it from the browser on the local machine.
The local machine is a weak macbook air, so I want to work on a powerful machine on the net. Also, if you can do this, you can work anywhere.
However, the ipython notebook is an interactive, graphical REPL that allows you to execute arbitrary code. This is also a huge security hole, so I would like to take measures that can be reassured.
The remote machine blocks all but the ssh port with a firewall, and the notebook is accessed via the ssh tunnel.
There is also a password protection method, but it is not adopted.
It will be the method on mac (I feel that it can be equivalent on windows).
For remote machines, use a firewall to prevent connections other than ssh.
Ssh to a remote machine. At this time, a "tunnel" is also opened. That is,
[local-machine]$ ssh -L 8080:127.0.0.1:8888 remotemachine
Connect with ssh as [^ 1]. This will open a "tunnel" at the same time that the usual ssh session is available in the terminal, so you can access localhost: 8080
to access remote port 8888 through the ssh session. Note that 8888
is the default port for notebooks.
[^ 1]: Suppose that remotemachine is already defined in ~ / .ssh / config
, and normally ssh remotemachine
is set to allow ssh connection.
On top of that
[remote-machine]$ ipython notebook --profile=nbserver --no-browser
As, start the notebook server [^ 2].
[^ 2]: When I try to launch a notebook without the --no-browser
option on a machine with a GUI, the browser launches and tries to open the notebook.
After starting the server, access localhost: 8080
with a browser on your local machine to open the notebook. On the other hand, accessing * ip-address-of-remote-machine *: 8888 is denied.
ssh connection lost. You can prevent the notebook server from going down by starting the notebook server in a screen or tmux session, but you need to ssh it again to connect to the browser. After all, is the official method (certificate + password) better?
Recommended Posts