• 服务器搭建远程Jupyter环境


    服务器搭建远程Jupyter环境

    方法一 ssh远程使用jupyter notebook

    在远程服务器上,启动jupyter notebooks服务:

    jupyter notebook --no-browser --port=8889
    
    • 1

    在本地终端中启动SSH:

    ssh -N -f -L localhost:8888:localhost:8889 username@serverIP
    
    • 1

    其中: -N 告诉SSH没有命令要被远程执行; -f 告诉SSH在后台执行; -L 是指定port forwarding的配置,远端端口是8889,本地的端口号的8888。

    注意:username@serverIP替换成服务器的对应账号。

    最后打开浏览器,访问:http://localhost:8888/

    方法二 利用jupyter notebook自带的远程访问功能

    1. 生成默认配置文件

    jupyter notebook --generate-config
    
    • 1

    2. 生成访问密码(token)

    终端输入ipython,设置你自己的jupyter访问密码,注意复制输出的sha1:xxxxxxxx密码串

    In [1]: from notebook.auth import passwd
    In [2]: passwd()
    Enter password:
    Verify password:
    Out[2]: 'sha1:xxxxxxxxxxxxxxxxx'
    
    • 1
    • 2
    • 3
    • 4
    • 5

    这里可能会遇到一种情况: 官方教程默认情况下生成sha1,但实际情况生成了argon2

    from notebook.auth import passwd
    passwd()
    Enter password:
    Verify password:
    Out[2]:'argon2:$argon2id$v=19$m=10240,t=10,p=8$pcTg1mB/X5a3XujQqYq/wQ$/UBQBRlFdzmEmxs6c2IzmQ'
    
    • 1
    • 2
    • 3
    • 4
    • 5

    显然新版本的jupyter更换了默认的生成方式

    解决办法passwd()中传入参数 algorithm='sha1'

    from notebook.auth import passwd
    passwd(algorithm='sha1')
    Enter password:
    Verify password:
    Out[2]: 'sha1:67c9e60bb8b6:9ffede08254254b2e042ea597d771089e11aed'
    
    • 1
    • 2
    • 3
    • 4
    • 5

    3. 修改.jupyter/jupyter_notebook_config.py中对应行如下

    vi ~/.jupyter/jupyter_notebook_config.py
    c.NotebookApp.ip='*'
    c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
    c.NotebookApp.open_browser = False
    c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口
    
    • 1
    • 2
    • 3
    • 4
    • 5

    4. 在服务器上启动jupyter notebook

    jupyter notebook
    
    • 1

    最后打开浏览器,访问:http://ip:8888/

    参考

    1. 远程访问服务器Jupyter Notebook的两种方法

    2. [jupyterlab密码设置不生成哈希值解决方法](

  • 相关阅读:
    Flink 侧输出流(SideOutput)
    【yocto】
    Nginx网关配置
    vue3 defineProps defineEmits defineExpose
    三角函数概述
    自动化运维工具Ansible
    verilog REG 寄存器、向量、整数、实数、时间寄存器
    【踩坑】parallel并发流导致数据异常
    服务器模拟互联网服务
    工作小记系列3-Minikube搭建笔记
  • 原文地址:https://blog.csdn.net/qq_39395755/article/details/128140207