Recently, because of the data to be analyzed, and the data exists in the server and the amount of data is large, copying to local is obviously more troublesome. It's natural to think of the Ipython notebook that you've just started using. Since Ipython notebook is based on Web service mode, we can open the Ipython server on the remote server and start the Ipython Web interface on the local client, which makes it easy to manipulate remote data.
The server system is Ubuntu 14.04, using the system pre-installed Python 2.7, and of course my other reason for using Python 2.7 is that it makes it easy to use the Scapy library (the Scapy library doesn't seem to support Python3 well).
The process of Ipython notebook remote Access configuration is documented as follows. 1. Installation of IPython and IPython notebook
This process is consistent with the installation process described in the previous "Ipython introduction," which is installed using the PIP management tool. First, under Terminal, install Ipython:
sudo pip install Ipython
Then install Ipython notebook:
sudo pip install Ipython notebook
2. Create login Password
Start Ipython on the server, generating the SHA1 of the custom password:
In [1]: From IPython.lib import passwd in
[2]: passwd ()
Enter password:
Verify password:
out[2]: ' sha1:0 26678de36b2:e4b83078e02c470b15789ade069359a20b0385dd '
Import the passwd method and call. After you enter the password two times, the program generates the SHA1 encrypted string for the password. To keep in mind the password you entered, and to record the generated encrypted string, use the following configuration. 3. Create Ipython Notebook server
Under Terminal, execute the following statement:
Ipython Profile Create MyServer
The MyServer here is a custom server name.
After execution, the command line has an output that tells us where the generated files are. Generally in/home/yourname/.ipython/profile_myserver/this folder, my username is Qiang, so the generated files in/home/qiang/.ipython/profile_myserver/ Folder.
We can go into the folder and look at the generated files:
Generally no problem, will generate ipython_config.py,ipython_kernel_config.py and ipython_notebook_config.py three files.
Our focus is on ipython_notebook_config.py this file, and later we will modify the file to configure the server. However, sometimes this file can not be generated, at this time we can create new here, using Vim or gedit. I did not generate ipython_notebook_config.py this file when I configured it myself, and I created a new one using gedit:
Gedit ipython_notebook_config.py
4. Modify ipython_notebook_config.py configuration file
In the file, enter the following configuration and save:
c = Get_config ()
# Kernel config
c.ipkernelapp.pylab = ' inline '
# notebook config
c.notebookapp.ip= ' * '
c.notebookapp.open_browser = False
c.notebookapp.password = U ' sha1:026678de36b2: E4b83078e02c470b15789ade069359a20b0385dd '
# it ' s a good idea to put it on a know,fixed port
c.notebookapp.port = 6 789
As you can see, the profile is configured with the IP address that you are listening to, the way the browser is opened by default, the login password, and the listening port. 5. Start Ipython Notebook server
Under Terminal, enter the following statement to start the Ipython notebook server:
Ipython Notebook--config=/home/qiang/.ipython/profile_myserver/ipython_notebook_config.py
In fact, it is best to use the Jupyter Notebook command, namely:
Jupyter Notebook--config=/home/qiang/.ipython/profile_myserver/ipython_notebook_config.py
As you can see, this command starts the Ipython notebook server and points to the configuration file we just edited.
If it's normal, we'll see output like this:
The Jupyter notebook is running At:http://[all IP addresses on your system]:6789/
6. This machine test
The IP address of my server is 172.16.1.126, enter 172.16.1.126:6789 test on my native browser:
After entering the password we just set, we can login successfully. 7. Extended use of HTTPS access
After completing the 6 steps above, we can use the HTTP protocol to access the Ipython notebook server, but sometimes for security reasons, such as our server is not built in the intranet, but on the public network, this time need to consider the security of data transmission, That is, to use HTTPS, you must have a certificate.
We can create self-signed certificates if we test ourselves, but you can also pay for a certificate. 7.1 Create a self-signed certificate
We can use OpenSSL to create a self-signed certificate, because it is self-signed so the browser prompts the warning, select Trust exception can be.
OpenSSL req-x509-nodes-days 365-newkey rsa:1024-keyout mycert.pem-out Mycert.pem
Here to remember the location of the generated Mycert.pem file, you can use the PWD command to view it. 7.2 Modifying the configuration file
At this point, we need to modify the ipython_notebook_config.py configuration file, in fact, only need to add a sentence in the file, this sentence indicates the location of the certificate:
c.notebookapp.certfile = U '/home/qiang/mycert.pem '
The configuration file is as follows:
c = Get_config ()
# Kernel config
c.ipkernelapp.pylab = ' inline '
# notebook config
c.notebookapp.ip= ' * '
c.notebookapp.certfile = R '/home/qiang/mycert.pem '
c.notebookapp.open_browser = False
c. Notebookapp.password = U ' sha1:026678de36b2:e4b83078e02c470b15789ade069359a20b0385dd '
# it ' s a good idea to put It on A know,fixed port
c.notebookapp.port = 6789
7.3 Running the server and using HTTPS tests on the computer
Once the above steps are complete, you can start the server again by using the following statement:
Jupyter Notebook--config=/home/qiang/.ipython/profile_myserver/ipython_notebook_config.py
Then on this computer, use HTTPS to access the following:
Run successfully. You can then use Ipython notebook on your computer to manipulate the data on the remote server.
Reference page: "Notebook-public-server"