Configuring your virtual server

Let's set up some basic configurations to leverage the power of Jupyter Notebooks to do our analyses and deep learning modeling on our virtual server without having to code on the Terminal all the time. First, we need to set up SSL certificates. Let's create a new directory:

ubuntu@ip:~$ mkdir ssl
ubuntu@ip:~$ cd ssl
ubuntu@ip:~/ssl$

Once we are in the directory, we leverage OpenSSL to create a new SSL certificate:

ubuntu@ip:~/ssl$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout "cert.key" -out "cert.pem" -batch 
Generating a 1024 bit RSA private key
......++++++
...++++++
writing new private key to 'cert.key'
-----
ubuntu@ip:~/ssl2$ ls
cert.key cert.pem

Now, we need to add that additional layer of password-based security to our Jupyter Notebooks, which we talked about earlier. For this, we need to modify Jupyter's default configuration settings. In case you do not have a config file for Jupyter, you can use the following command to generate it:

$ jupyter notebook --generate-config

To enable password-based security for the notebooks, we need to first generate a password and its hash. We can leverage the passwd() function in Ipython.lib as follows:

ubuntu@ip:~$ ipython
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:e9ed12b73a30:142dff0cdcaf375e4380999a6ca17b47ce187eb6'
In [3]: exit
ubuntu@:~$

Once you enter your password and verify it, the function returns a hash to you, which is the hash of your password (in this case, the password key I typed was literally the word password, which is something you should definitely not be using!). Copy and save that hash value since we will need it soon.

Next, fire up your favorite text editor to edit the Jupyter config file, as follows:

ubuntu@ip:~$ vim ~/.jupyter/jupyter_notebook_config.py


# Configuration file for jupyter-notebook.

c = get_config() # this is the config object
c.NotebookApp.certfile = u'/home/ubuntu/ssl/cert.pem'
c.NotebookApp.keyfile = u'/home/ubuntu/ssl/cert.key'
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = 'sha1:e9ed12b73a30:142dff0cdcaf375e4380999a6ca17b47ce187eb6' # replace this

# press i to insert new text and then press 'esc' and :wq to save and exit

ubuntu@ip:~$

We will now look at some essential dependencies for enabling deep learning before we can start building our models.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.23.79.149