sudospowner:使用sudo的jupyterhub的产卵器

sudospawner的Python项目详细描述


苏多斯帕纳

PyPI

sudospowner启用JupyterHub 通过生成中间服务器,在不作为根用户的情况下生成单用户服务器 通过代表用户执行操作的sudo进行处理。

中间过程sudospawner中介只能做两件事:

  1. 使用os.kill()调用向另一个进程发送信号
  2. 生成单用户服务器

启动sudospawner脚本是唯一需要 jupyterhub管理员有权执行sudo访问。

安装和设置

  1. 安装:

     pip install -e .
    
  2. Add sudo access to the script

  3. 要将jupyterhub配置为使用sudospowner,请在 jupyterhub_config.py

     c.JupyterHub.spawner_class='sudospawner.SudoSpawner'
    

    那张JupyterHub documentation 有关于creating a configuration file的其他信息, 如果需要,以及配置文件的建议文件位置。

自定义单用户启动命令

为了限制sudospowner授予集线器的权限, 启动单用户服务器时 生成的可执行文件硬编码为dirname(sudospawner)/jupyterhub-singleuser。 这要求sudospawner可执行文件与jupyterhub-singleuser命令位于同一目录中。 非常重要用户不能修改包含sudospawnerbin/目录, 否则,它们可以修改sudospawner实际启用jupyterhub的功能。

您可能需要在启动服务器之前初始化用户环境变量,或者执行其他初始化。 如果在sudospawner旁边安装名为sudospawner-singleuser的脚本, 这将代替直接的jupyterhub-singleuser命令。

例如,您可能希望从conda环境中派生笔记本服务器,这些环境是与集线器实例分开修改和部署的。

#!/bin/bash -lset -e

# Activate the notebook environmentsource /opt/miniconda/bin/activate /opt/envs/notebook-latest

# Show environment info in the log to aid debugging
conda info

# Delegate the notebook server launch to the jupyterhub-singleuser script.# this is how most sudospawner-singleuser scripts should end.exec"$(dirname "$0")/jupyterhub-singleuser"$@

sudospowner与jupyterlab hub单用户启动命令

为了让sudospowner与jupyterlab hub一起工作,您需要创建一个自定义的单用户启动命令。 在与sudospawner相同的目录中创建包含以下代码的脚本sudospawner-singleuser,并授予其相同的权限。

#!/bin/bash -l# Delegate the notebook server launch to the jupyter-labhub script.exec"jupyter-labhub"$@

示例

此repo中的Dockerfile包含用于设置jupyterhub系统的示例配置,无需以根用户身份运行任何内容。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android Action_Edit Intent无法像以前一样调用App Gallery来编辑图片   确保JRE兼容性的java适当程序(32或64位)   java JSONArray。for循环中的add(JSONObject)正在替换for循环中的旧值,数组由循环中的最后一个值组成   java需要帮助创建一个返回数组的方法,该数组的元素是另一个数组的平方   使用SmbFile w/groovy XmlSluper()创建xml。解析()Java   检查大小后的java ArrayIndexOutOfBoundsException   乘法表中的第k个最小元素   java 401 on请求,其中指定了'permitAll()'   java如何附加ORC文件   java hibernate类模型   java IDEA没有看到由自定义注释处理器生成的方法   Servlet中未声明java SerialVersionId   java linkedlist到达列表末尾时   java如何正确对齐EditText光标?   java 6编译器1.6上的eclipse重写方法错误   java如何在基于Jersey的RESTful Web服务中读取post数据   java如何在活动中正确使用接口?   Java的JIT编译器的工作速度有多快?