sudo apt-get update
sudo apt-get upgrade
sudo apt-get install iptables
root@0f3aa94e61af:~/# sudo apt-get install lsof
pip install jupyter
安装好jupyter之后,使用如下命令生产配置文件.jupyter。
root@0f3aa94e61af:~# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
root@0f3aa94e61af:~# ls -lta
total 140
drwxrwxr-x 1 root root 4096 Aug 11 16:06 .
drwx------ 2 root root 4096 Aug 11 16:06 .jupyter
-rw------- 1 root root 6660 Aug 11 16:06 .bash_history
drwxr-xr-x 3 root root 4096 Aug 11 14:38 jupyter
-rw------- 1 root root 1024 Aug 11 14:24 .rnd
-rw------- 1 root root 352 Aug 11 14:24 .python_history
drwxr-xr-x 5 root root 4096 Aug 10 11:48 face_detect
drwx------ 1 root root 4096 Aug 9 12:04 .cache
drwxr-xr-x 1 root root 4096 Aug 9 12:02 .config
drwxr-xr-x 1 root root 4096 Aug 9 11:56 ..
-rw-r--r-- 1 root root 3158 Jul 2 06:29 .bashrc
drwxr-x--- 3 root root 4096 Jul 2 04:20 .theano
-rw-r--r-- 1 root root 762 Jul 2 04:17 pip3
-rw-r--r-- 1 root root 762 Jul 2 04:16 pip
drwxr-xr-x 2 root root 4096 Jun 29 08:08 .keras
-rw-r--r-- 1 root root 572 Jun 22 09:59 Jupyter_hash_password.txt
drwx------ 1 root root 4096 Jun 15 02:00 .local
drwx------ 1 root root 4096 Jun 15 02:00 Desktop
drwx------ 2 root root 4096 Jun 15 01:56 .ssh
drwx------ 3 root root 4096 Jun 5 06:30 .nv
drwxr-xr-x 18 root root 4096 Jun 5 06:27 caffe
drwxr-xr-x 1 root root 4096 Jun 5 05:13 .vscode
drwx------ 3 root root 4096 Jun 5 05:13 .pki
-rw-r--r-- 1 root root 3106 Jun 5 05:11 .bashrc-anaconda3.bak
drwx------ 1 root root 4096 Jun 5 04:57 .dbus
drwx------ 5 root root 4096 Jun 5 04:57 .mozilla
drwx------ 4 root root 4096 Jun 5 04:56 .thumbnails
-rw-rw-r-- 1 root root 59 Apr 22 15:03 .asoundrc
-rw-rw-r-- 1 root root 619 Apr 22 15:03 .gtkrc-2.0
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
root@0f3aa94e61af:~#
配置文件在
cd ~/.jupyter
配置一个ssl(https的访问)
cd ~/.jupyter 切换到.jupyter目录
openssl req -x509 -nodes -days 90000 -newkey rsa:1024 -keyout mykey.key -out mycert.pem
成功的话,会在.jupyter目录下面产生 mykey.key 和 mycert.pem 两个文件
接着我们就可以使用带ssl的Jupyter notebook服务了:
jupyter notebook --certfile=mycert.pem --keyfile mykey.key
alex@ibm:~$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'sha1:baa06a970751:e79f6e89639acbe170dee76e469b6282bfd67c1e'
>>>
openssl req -x509 -nodes -days 90000 -newkey rsa:1024 -keyout mykey.key -out mycert.pem
#mycert.pem
#mykey.key
jupyter notebook --certfile=/home/alex/.jupyter/mycert.pem --keyfile /home/alex/.jupyter/mykey.key
jupyter notebook --no-browser --allow-root
jupyter notebook --ip=183.6.102.71 --no-browser --allow-root
jupyter notebook --ip=127.0.0.1 --no-browser --allow-root
kill process about port
root@0f3aa94e61af:~# netstat -an|grep 20066
tcp 0 0 0.0.0.0:20066 0.0.0.0:* LISTEN
root@0f3aa94e61af:~# lsof -i:20066
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
jupyter-n 23537 root 4u IPv4 85581222 0t0 TCP *:20066 (LISTEN)
root@0f3aa94e61af:~# kill -9 23537
root@0f3aa94e61af:~# lsof -i:20066
root@0f3aa94e61af:~#
sudo iptables -t nat -A OUTPUT -d 127.0.0.1 -j DNAT --to-destination 183.6.102.71
sudo iptables -t nat -A OUTPUT -d 127.0.0.1 -j DNAT --to-destination 192.168.0.112
>>>
>>>
>>>
>>>
>>>
>>>
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
Passwords do not match.
Enter password:
Verify password:
'sha1:87a20a028351:ffd4cea83c3d01c9866b05c9183cb7853357aa1f'
>>>
openssl req -x509 -nodes -days 90000 -newkey rsa:1024 -keyout mykey.key -out mycert.pem
jupyter notebook --certfile=mycert.pem --keyfile mykey.key
使用xshell,远程设置云服务器访问note jupyter
jupyter notebook --ip=127.0.0.1 --no-browser --allow-root --port=8888
在本地浏览器访问https://localhost:8888,就可以访问notejupyter