Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. On the remote machine, start the IPython notebooks server:
  2.  
  3. remote_user@remote_host$ ipython notebook --no-browser --port=8889
  4.  
  5. Usually IPython opens a browser to display the available notebooks, but we do not need that so we use the option --no-browser. We also change the port to 8889, for no other reason than to show how this is done.
  6.  
  7. On the local machine, start an SSH tunnel:
  8.  
  9. local_user@local_host$ ssh -N -f -L localhost:8888:localhost:8889 remote_user@remote_host
  10.  
  11. The first option -N tells SSH that no remote commands will be executed, and is useful for port forwarding. The second option -f has the effect that SSH will go to background, so the local tunnel-enabling terminal remains usable. The last option -L lists the port forwarding configuration (remote port 8889 to local port 8888).
  12.  
  13. Now open your browser on the local machine and type in the address bar
  14.  
  15. localhost:8888
  16.  
  17. which displays your remotely running IPython notebook server.
  18.  
  19. To close the SSH tunnel on the local machine, look for the process and kill it manually:
  20.  
  21. local_user@local_host$ ps aux | grep localhost:8889
  22. local_user 18418 0.0 0.0 41488 684 ? Ss 17:27 0:00 ssh -N -f -L localhost:8888:localhost:8889 remote_user@remote_host
  23. local_user 18424 0.0 0.0 11572 932 pts/6 S+ 17:27 0:00 grep localhost:8889
  24.  
  25. local_user@local_host$ kill -15 18418
  26.  
  27. Alternatively, you can start the tunnel without the -f option. The process will then remain in the foreground and can be killed with ctrl-c.
  28.  
  29. On the remote machine, kill the IPython server with ctrl-c ctrl-c.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement