为什么 Jupyter 在 vagrant VM 上托管时需要未知密码?
Why does Jupyter require an unknown password when hosted on a vagrant VM?
我正在尝试使用 python 设置一个 vagrant box,并使用 Jupyter 从我的浏览器在主机上编写 运行 代码。这是一个最小的例子:
Vagrantfile
:
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.network :forwarded_port, guest: 8888, host: 8888
config.vm.provision "shell", inline: <<-SHELL
apt-get install -y python-dev python-pip
pip install jupyter
SHELL
end
在我的 windows 主机 cmd 中,我在与 Vagrantfile
:
相同的目录中执行这些命令
> vagrant up
> vagrant ssh
~$ jupyter notebook --no-browser --ip=0.0.0.0
然后我在我的 windows 主机上导航到 Chrome 中的 localhost:8888
,却发现一个 Jupyter 登录页面要求输入我从未设置过的密码。我试过不输入密码和 "vagrant" 以防它链接到 VM 的密码。
为什么 Jupyter 要求我输入密码?
本文 comment 涵盖了最近对 Jupyter 的更改。
如果你这样做:
jupyter notebook list
这将为您提供您需要然后传入的令牌:
http://localhost:8888/?token=yourToken
第一次启动notebook时,token也会输出到控制台:
vagrant@vagrant-ubuntu-trusty-64:~$ jupyter notebook --no-browser --ip=0.0.0.0
Serving notebooks from local directory: /home/vagrant
0 active kernels
The Jupyter Notebook is running at: http://0.0.0.0:8888/?token=yourToken
还有一种方法可以完全禁用 jupyter 身份验证,方法是在 jupyter_notebook_config.py 中将 NotebookApp.token 设置为空字符串,或者在启动服务器时使用类似以下内容的内容:
jupyter notebook --no-browser --ip=0.0.0.0 --NotebookApp.token=''
这本质上是不安全的,可能仅在您的本地环境中用于开发目的才可接受。
我正在尝试使用 python 设置一个 vagrant box,并使用 Jupyter 从我的浏览器在主机上编写 运行 代码。这是一个最小的例子:
Vagrantfile
:
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.network :forwarded_port, guest: 8888, host: 8888
config.vm.provision "shell", inline: <<-SHELL
apt-get install -y python-dev python-pip
pip install jupyter
SHELL
end
在我的 windows 主机 cmd 中,我在与 Vagrantfile
:
> vagrant up
> vagrant ssh
~$ jupyter notebook --no-browser --ip=0.0.0.0
然后我在我的 windows 主机上导航到 Chrome 中的 localhost:8888
,却发现一个 Jupyter 登录页面要求输入我从未设置过的密码。我试过不输入密码和 "vagrant" 以防它链接到 VM 的密码。
为什么 Jupyter 要求我输入密码?
本文 comment 涵盖了最近对 Jupyter 的更改。
如果你这样做:
jupyter notebook list
这将为您提供您需要然后传入的令牌:
http://localhost:8888/?token=yourToken
第一次启动notebook时,token也会输出到控制台:
vagrant@vagrant-ubuntu-trusty-64:~$ jupyter notebook --no-browser --ip=0.0.0.0
Serving notebooks from local directory: /home/vagrant
0 active kernels
The Jupyter Notebook is running at: http://0.0.0.0:8888/?token=yourToken
还有一种方法可以完全禁用 jupyter 身份验证,方法是在 jupyter_notebook_config.py 中将 NotebookApp.token 设置为空字符串,或者在启动服务器时使用类似以下内容的内容:
jupyter notebook --no-browser --ip=0.0.0.0 --NotebookApp.token=''
这本质上是不安全的,可能仅在您的本地环境中用于开发目的才可接受。