3、ssh、jupyter、vscode在Linux部署

这里写目录标题

1、ssh

复制代码
# ssh 安装 
apt-get update
apt-get install openssh-server -y
apt-get install openssh-client -y
apt-get install ssh -y
apt-get install vim -y
passwd
vim /etc/ssh/sshd_config
# 在sshd_config 中加入一下代码, 注意单词拼写
        PermitRootLogin yes
        port=22       
        PubkeyAuthentication yes
        PasswordAuthentication yes
service ssh restart 

开机启动

链接:https://blog.csdn.net/qq_38603541/article/details/124028994

1、正常我们在linux操作系统内设置服务自启动的方法一般都是使用systemctl。

systemctl enable ssh

2、但是,一般在docker容器内我们一般不这么干,因为容器内没有systemctl权限......

4、在 /root 目录下新建一个 start_ssh.sh文件,并给予该文件可执行权限。

复制代码
touch /root/start_ssh.sh
vim /root/start_ssh.sh
chmod +x /root/start_ssh.sh

5、start_ssh.sh 脚本的内容,如下:

shell 复制代码
#!/bin/bash
 
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
echo "[$LOGTIME] startup run..." >>/root/start_ssh.log
service ssh start >>/root/start_ssh.log
#service mysql start >>/root/star_mysql.log   //其他服务也可这么实现

5、将start_ssh.sh脚本添加到启动文件中

vim /root/.bashrc

shell 复制代码
# startup run
if [ -f /root/ssh/start_ssh.sh ]; then
     bash /root/ssh/start_ssh.sh >/root/ssh/error.log 2>&1
fi

重启ssh服务

service ssh restart

systemctl restart sshd

2、Jupyter

复制代码
#安装jupyter
pip install jupyter

#生成jupyter配置文件,这个会生成配置文件.jupyter/jupyter_notebook_config.py
jupyter notebook --generate-config

#使用python交互窗口生成密码
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: 
Verify password: 
Out[2]: 'sha1:******'

#去配置文件.jupyter/jupyter_notebook_config.py中修改以下参数
c.NotebookApp.ip='*'                          #绑定所有地址
c.NotebookApp.password = u'刚才生成的密码'
c.NotebookApp.open_browser = False            #启动后是否在浏览器中自动打开
c.NotebookApp.port =8888                      #指定一个访问端口,默认8888,注意和映射的docker端口对应

#启动jupyter 服务
cd  /你想要保存脚本的路径
jupyter notebook --allow-root

#后台运行jupyter notebook
jupyter notebook --allow-root > jupyter.log 2>&1 &
# 关闭
ps -axu | grep jupyter 
kill -9 PID

3、vscode网页版

项目地址:https://github.com/coder/code-server?tab=readme-ov-file

bash 复制代码
使用安装 脚本,其中 自动化大部分流程。如果出现以下情况,则该脚本使用系统包管理器 可能。
如果使用安装脚本,则可以预览安装过程中发生的情况 过程:

curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
要安装,请运行:
curl -fsSL https://code-server.dev/install.sh | sh

#运行
export PASSWORD="配置一个密码"
code-server --port 8888 --host 0.0.0.0 --auth password
参考博客:https://blog.csdn.net/muxuen/article/details/130334319

如何在VSCode中添加Python解释器

步骤1:安装Python插件

在开始之前,你需要在VSCode中安装Python插件。以下是如何做到这一点的步骤:

  1. 打开VSCode。
  2. 点击左侧工具栏上的Extensions按钮(四个方块组成的图标)。
  3. 在搜索框中输入"Python"。
  4. 在搜索结果中找到"Python",点击"Install"按钮。

步骤2:打开命令面板

接下来,你需要打开VSCode的命令面板。可以通过以下步骤实现:

  1. 在VSCode中,按F1键或组合键Ctrl+Shift+P打开命令面板。

步骤3:选择Python解释器

在命令面板中,你可以选择Python解释器。以下是操作步骤:

  1. 在命令面板中,输入"Python: Select Interpreter"并回车。
  2. 在弹出的列表中,选择你希望使用的Python解释器。
    链接:https://blog.csdn.net/Dontla/article/details/112655378
相关推荐
小乔的编程内容分享站2 小时前
记录使用VSCode调试含scanf()的C语言程序出现的两个问题
c语言·开发语言·笔记·vscode
mancy_1212126 小时前
复古C语言代码复活!——以121+hello.c为例摘要
c语言·vscode·gitee·visual studio·新人首发·turbo c
BUTCHER57 小时前
GitLab SSH 密钥配置
运维·ssh·gitlab
Honmaple10 小时前
OpenClaw 远程访问配置指南:SSH 隧道与免密登录
运维·ssh
qq_3975623110 小时前
使用vscode , 开发keil单片机工程 . (为了使用ai助手)
ide·vscode·编辑器
于慨10 小时前
nuxt4项目安装依赖报错
vscode
测试开发Kevin11 小时前
如何解决vscode使用远程资源管理常见问题:远程主机可能不符合 glibc 和 libstdc++ VS Code 服务器的先决条件
vscode
FansyMeng1 天前
VSCode配置anaconda
vscode·python
视觉AI1 天前
【踩坑实录】Windows ICS 共享网络下,国产化盒子 SSH 连接异常的完整分析
网络·windows·ssh
Anarkh_Lee1 天前
在VSCode中使用MCP实现智能问数
数据库·ide·vscode·ai·编辑器·ai编程·数据库开发