You know how you run a server when you run
jupyter notebook? It works exactly the same on your Digital Ocean server!
…except you can’t connect to it! We could talk forever about
localhost, but basically it turns out Jupyter and Digital Ocean are a little too secure for you to connect to the Jupyter Notebook server!
We could spend time making it less secure, but that seems like a silly thing to do. Let’s do this right.
What we’re going to do is something called ssh tunneling - we’re going to use
ssh to connect to our server, then have it redirect a port on our machine to a port on the server. That way we never expose the Jupyter server to the internet, it’s all directed through our connection with the server.
ssh -i ~/.ssh/algorithms_key root@YOUR_IP_ADDRESS -L 7777:localhost:7777 -t "jupyter notebook --no-browser --port 7777 --allow-root"
-i algorithms_keyuses the key we made before
root@YOUR_IP_ADDRESSlogs in as
rootas the IP address (actually type yours in!)
-L 7777:localhost:7777redirects port
7777on our machine to the same port on the server
-tmeans “we’re going to run a command once we connect”
jupyter notebook --no-browser --port 7777 --allow-rootruns a Jupyter Notebook server on the remote machine on
Now to visit the server, just go to http://localhost:7777. And when you’re done, all you need to do is ctrl+c on the remote server.