vps配置jupyterlab远程访问服务

vps配置jupyterlab远程访问服务 撸了个小鸡鸡,打算用来做jupyter server,在此记录下此次配置全过程。 安装JupyterLab # 更新系统 apt update&&apt upgrade -y # 安装python apt install python3 #安装JpyterLab和中文语言 pip3 install jupyterlab jupyterlab-language-pack-zh-CN 配置jupyterlab 生成配置文件,存放路径为.jupyter/jupyter_lab_config.py root@hcss-ecs-279f:~# jupyter lab --generate-config Writing default config to: /root/.jupyter/jupyter_lab_config.py 编辑配置文件vi .jupyter/jupyter_lab_config.py,参考以下配置 # 允许任意IP访问 c.ServerApp.allow_origin = '*' c.ServerApp.ip = '0.0.0.0' # 自定义端口号 c.ServerApp.port = 8888 # 允许root运行 c.ServerApp.allow_root = True 下来设置访问密码 root@hcss-ecs-279f:~# jupyter lab password Enter password: Verify password: [JupyterPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_server_config.json 然后就可以使用jupyter lab来运行服务。 root@hcss-ecs-279f:~# jupyter lab ... ... [I 2025-04-10 10:41:35.533 ServerApp] jupyterlab | extension was successfully loaded. [I 2025-04-10 10:41:35.536 ServerApp] notebook | extension was successfully loaded. [I 2025-04-10 10:41:35.537 ServerApp] Serving notebooks from local directory: /root [I 2025-04-10 10:41:35.537 ServerApp] Jupyter Server 2.15.0 is running at: [I 2025-04-10 10:41:35.537 ServerApp] http://hcss-ecs-279f:9876/lab [I 2025-04-10 10:41:35.537 ServerApp] http://127.0.0.1:9876/lab ... ... 按提示通过IP:9876方式来远程访问JupyterLab服务即可。 ...

四月 10, 2025 · JQX

Debian12安装fail2ban加固服务器安全

Debian12安装fail2ban加固服务器安全 fail2ban 是一款用于保护服务器免受暴力破解攻击的工具,通过监控日志文件检测恶意行为,并自动触发防火墙规则封禁可疑 IP。 Debian12下安装fail2ban过程如下: 先安装必备软件 apt install git python3 python3-setuptools 从源码安装fail2ban git clone https://github.com/fail2ban/fail2ban.git cd fail2ban sudo python setup.py install systemd设置fail2ban服务 cd fail2ban cp ./build/fail2ban.service /etc/systemd/system/ systemctl enable fail2ban systemctl start fail2ban 检查服务状态 root@box:~# systemctl status fail2ban.service * fail2ban.service - Fail2Ban Service Loaded: loaded (/etc/systemd/system/fail2ban.service; enabled; preset: enabled) Active: active (running) since Tue 2025-04-08 02:54:18 CDT; 12min ago Docs: man:fail2ban(1) Process: 2066 ExecStartPre=/bin/mkdir -p /run/fail2ban (code=exited, status=0/SUCCESS) Main PID: 2067 (fail2ban-server) Tasks: 3 (limit: 352) Memory: 12.8M CPU: 195ms CGroup: /system.slice/fail2ban.service `-2067 /usr/bin/python3 /usr/local/bin/fail2ban-server -xf start Apr 08 02:54:18 box systemd[1]: Starting fail2ban.service - Fail2Ban Service... Apr 08 02:54:18 box systemd[1]: Started fail2ban.service - Fail2Ban Service. Apr 08 02:54:19 box fail2ban-server[2067]: Server ready ssh配置实例,新建/etc/fail2ban/jail.local文件,内容如下: ...

四月 8, 2025 · JQX

pip设置代理的几种方法

pip设置代理的几种方法 通常情况下,国内使用PIP可以参考Pypi国内镜像设置来设置国内镜像以加快安装速度。 但有的pip软件包国内镜像出于各种考虑并未收录,因此就得使用Pipy.org的官方源安装,在网络状况不理想的情况下,我们可以使用设置代理来加速安装过程。 例如,我们已经获得了代理服务的配置,如下: http://127.0.0.1:2080 socks://127.0.0.1:2080 如果是linux系统,可以使用系统自有的环境变量http_proxy、https_proxy $ export HTTP_PROXY=http://127.0.0.1:2080 $ export HTTPS_PROXY=http://127.0.0.1:2080 使用pip自带选项--proxy来使用代理 $ pip install --proxy=http://127.0.0.1:2080 jupyter 使用pip配置文件pip.conf或pip.ini来设置代理 Windows下是pip.ini,linux下是~/.pip/pip.conf或/etc/pip.conf [global] proxy = http://127.0.0.1:2080

十二月 12, 2024 · JQX

使用pandoc批量转换rst为md

使用pandoc批量转换rst为md 安装软件pandoc 下载安装pandoc Windows版下载安装pandoc-3.5-windows-x86_64.msi (访问密码: 3705) Debian/Ubuntu使用如下命令安装 apt install pandoc 安装Python Windows版下载安装python-3.13.0-amd64.exe (访问密码: 3705) Debian/Ubuntu使用如下命令安装 apt install python3 python3-pip 安装Pypandoc Pypandoc是一款python插件,可以调用Pandoc进行使用。 pip install pypandoc Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting pypandoc Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ff/bd/cf1dd70b95f3366f3c457c5259ed8f032122210441407b6ed281d7fcbb8c/pypandoc-1.14-py3-none -any.whl (21 kB) Installing collected packages: pypandoc Successfully installed pypandoc-1.14 Python代码 新建plzh.py文件,内容如下,或者点击这里下载文件plzhrst2md.py (访问密码: 3705) import os def get_file_name(file_dir): for root, dirs, files in os.walk(file_dir): #获取当前目录 for file in files: if os.path.splitext(file)[1] == ".rst": #搜索rst文件 os.chdir(root) print("Conversion ..." + "pandoc " + file + " -o " + os.path.splitext(file)[0] + ".md") os.system("pandoc " + file + " -o " + os.path.splitext(file)[0] + ".md") #调用pandoc开始转换到同目录 print("Done!") if __name__ == "__main__": get_file_name(r"D:\dls\doc") #自定义文件夹 将文件复制到.rst文件目录,点击运行即可,转换后的.md文件和.rst文件同目录同文件名。

十一月 20, 2024 · JQX

Pypi国内镜像设置

Pypi国内镜像设置 PyPI(Python包索引)是最流行的Python软件存储库,使用Pypi可查找与安装由Python社区开发和共享的软件。 由于线路问题,国内通过pypi默认镜像安装或更新软件时可能会很慢,此种情况可以通过配置国内镜像来改善。 pypi临时使用国内镜像 临时使用国内镜像来安装jupyter pip install -i https://mirror.nju.edu.cn/pypi/web/simple jupyter 临时使用国内镜像来升级pip python -m pip install -i https://mirror.nju.edu.cn/pypi/web/simple --upgrade pip 设置pypi默认镜像 通过以下方法可以设置默认镜像 pip config set global.index-url https://mirror.nju.edu.cn/pypi/web/simple 国内pypi镜像列表 https://mirror.nju.edu.cn/pypi/web/simple 南京大学 https://mirrors.bfsu.edu.cn/pypi/web/simple 北京外国语大学 https://mirrors.neusoft.edu.cn/pypi/web/simple/ 大连东软信息学院 https://mirrors.jlu.edu.cn/pypi/simple/ 吉林大学 https://mirrors.njtech.edu.cn/pypi/web/simple/ 南京工业大学 https://mirror.nyist.edu.cn/pypi/web/simple/ 南阳理工学院 https://mirrors.pku.edu.cn/pypi/web/simple/ 北京大学 https://mirrors.sustech.edu.cn/pypi/web/simple 南方科技大学 https://pypi.tuna.tsinghua.edu.cn/simple 清华大学

七月 30, 2024 · JQX