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第三方库


热门话题
Cassandra DB的javascript查询结果   java定时器任务调度   java在TLS上实现LDAP   为什么在浏览器中滚动会使java小程序闪烁?   未使用轮询器和serviceactivator提取java pubsub消息   java风暴多线程问题   java计算平均成绩   java将字符串添加到另一个类的数组列表中   文件Java路径如何转换为例如InputStream   java更改JComboBox的字体颜色   java inthttp:具有可轮询请求通道的inboundgateway   使用继承在Java中运行swing Base和扩展windows   java ivysettings。xml:添加本地maven路径   java如何将参数自定义视图传递给activity类   java延迟加载无法在Hibernate中使用一对一映射   当文件以“file:/”开头时,Java无法识别该文件   需要java正则表达式帮助,使用反斜杠   片段中的java GWT参数