在Fedora 28上配置JupyterHub

最近迁移一些服务到NekomimiRouter.com的新服务器上,顺便尝试一下新发行版。

安装与配置

首先更新一下系统

sudo pkcon refresh
sudo pkcon update

安装必要的包(python3 和python3-pip 应该有预装)

sudo pkcon install npm
sudo -H npm install -g configurable-http-proxy
sudo -H pip3 install jupyterhub notebook jupyterhub-systemdspawner ipyparallel
sudo ipcluster nbextension enable

设置防火墙(我比较懒就直接写端口了)

sudo systemctl --zone=FedoraServer --permanent --add-port=8000/tcp

创建默认配置文件,应用一些安全配置

# run as root
mkdir -p /etc/jupyterhub
cd /etc/jupyterhub && jupyterhub --generate-config
cat <<EOF >>jupyterhub_config.py
c.JupyterHub.spawner_class = 'systemdspawner.SystemdSpawner'
c.JupyterHub.cleanup_proxy = True
c.JupyterHub.cleanup_servers = True
c.SystemdSpawner.isolate_tmp = True
c.SystemdSpawner.isolate_devices = True
c.SystemdSpawner.disable_user_sudo = True
c.SystemdSpawner.readonly_paths = ['/']
c.SystemdSpawner.readwrite_paths = ['/home/{USERNAME}', '/tmp']
EOF

设置随系统启动

# run as root
cat <<EOF >/etc/systemd/system/jupyterhub.service
[Unit]
Description=Jupyterhub
After=network-online.target

[Service]
User=root
ExecStart=/usr/local/bin/jupyterhub
WorkingDirectory=/etc/jupyterhub

[Install]
WantedBy=multi-user.target
EOF
systemctl enable --now jupyterhub

备注

如果你这台机子加了Kerberos统一认证(比如我这台加了Active Directory),那么需要注意几个问题:

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据