conda配置jupyter密码并远程访问

jupyter notebook --generate-config
vi  /home/kewei/.jupyter/jupyter_notebook_config.py

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
改了这些配置,发现还是连不上。
于是:

1. 安装Jupyter

pip3 install jupyter

2. 生成jupyter配置文件

jupyter notebook --generate-config

此时会提示生成一个文件在 .jupyter/jupyter_notebook_config.py

python

进入python环境后输入

from IPython.lib import passwd
passwd()

会提示输入密码(自己随意设置一个就好,记下来,一会会用到),确认密码,之后会返回一个序列
在这里插入图片描述
在这里密码记为‘shal:5d429542e711…’

3. 修改jupyter配置文件

打开刚刚生成的文件 .jupyter/jupyter_notebook_config.py (注意它在隐藏目录.jupyter/里)
在末尾加上

c.NotebookApp.ip = '*'
c.NotebookApp.port = 6000 // 在服务器上运行的端口号,自己随意设置
c.NotebookApp.password = u'刚刚生成的密码序列'
c.NotebookApp.open_browser = False

4. 启动jupyter

输入命令
建议在根目录(如/home/name/)下输入

jupyter notebook --no-browser

例如会显示
在这里插入图片描述
注意红色框出了返回的一个地址,这个地址6000代表刚刚设置的端口号,node001代表我的服务器名称(每个人是不同的)待会要用到

5. 方法一:设置MobaXterm的Tunneling

打开
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 6001:自己设置的本地运行的端口,例如设置为6001,则待会就在浏览器中输入http://localhost:6001
  • 6000:刚刚在jupyter_notebook_config.py文件中设置的端口号,也是服务器运行的端口号
  • <Remote server>:服务器运行的名字,这个主要看刚刚红框里面的内容即http://node001:6000/的话就是node001
  • <SSH server>:就是你的服务器的地址,例如202.123.45.87
  • name: 服务器用户名
  • <SSH server>:服务器的端口号

6. 在浏览器输入

http://localhost:6001(6001是刚刚设置的本地运行的端口号)
第一次打开要输入密码,密码输入的是第2步中你自己设置的密码(不是那一长串序列)就可以打开啦!

如果上面行不通,关键是方法二:

为了能够远程访问这台机器上的MySQL,需要开放3306端口:

[root@localhost ~]# service iptables status
Redirecting to /bin/systemctl status  iptables.service
Unit iptables.service could not be found.

安装 iptables-services:

yum install iptables-services

启动 iptables:

service iptables start

编辑配置文件,将8888~8890端口添加到22端口下:

vi /etc/sysconfig/iptables

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8888 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8889 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8890 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

重启:

service iptables restart

查看开放端口:

[root@localhost ~]# /sbin/iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:3306
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
[root@localhost ~]#

远端就能通过telnet 测试访问了:

telnet 192.168.1.27 8888
为了配置condajupyter,你可以按照以下步骤进行操作: 1. 首先,你需要创建一个名为"环境名"的conda环境并导出备份文件。使用以下命令将环境导出为一个备份列表: `conda env export > bak.yml` 2. 然后,你需要安装jupyter。使用以下命令安装jupyter: `pip install jupyter` 3. 接下来,你需要生成jupyter配置文件。使用以下命令生成配置文件: `jupyter notebook --generate-config` 4. 打开生成的配置文件,可以使用以下命令: `vim ~/.jupyter/jupyter_notebook_config.py` 5. 在配置文件中,你可以配置jupyter的各种选项,如密码、端口号等。 这样,你就可以成功配置condajupyter了。请记住,使用jupyter创建的Python文件后缀为".ipynb"。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [conda环境配置+jupyter配置](https://blog.csdn.net/qq_34649947/article/details/113495530)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [anacondajupyter安装配置](https://blog.csdn.net/qq_47844519/article/details/125639102)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

irrationality

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值