[Level 1] Create secure web for iPython notebook.

The default protocol for iPython notebook is http and you didn't passphrase to enter notebook. If you want your notebook be secure, you could follow the steps to enable SSL and passphrase for it. 1. create profile:
In [1]: ## create profile for secure web
        !ipython profile create secureweb
2. create passphrase:
In [2]: ## create passphrase
        from IPython.lib import passwd
        passwd(passphrase='passphrase')
Out[2]: 'sha1:24be7c5ab59a:b8b7d3c691b2db67a5ef855b625cb560e125e5e1' 3. Create SSL certificate
$ cd /home/stanley/iPython_notebook/certs
$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
Generating a 1024 bit RSA private key
..............++++++
..........++++++
writing new private key to 'mycert.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Taipei
Organization Name (eg, company) [Internet Widgits Pty Ltd]:StanleyHuang
Organizational Unit Name (eg, section) []:Stanley
Common Name (e.g. server FQDN or YOUR name) []:Stanley
Email Address []:wenlien1001@gmail.com
$
4. Modify iPython notebook config.
$ cat ~/.config/ipython/profile_secureweb/ipython_notebook_config.py
c = get_config()
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.certfile = u'/home/stanley/iPython_notebook/certs/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:24be7c5ab59a:b8b7d3c691b2db67a5ef855b625cb560e125e5e1'
c.NotebookApp.port = 9999
...
$
5. Restart iPython notebook, login with https protocol and enter the passphrase.
$ ipython notebook --profile=secureweb

Wish this helps.

regards,
Stanley Huang

Comments

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python