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
相关推荐
联系QQ 180809518 分钟前
基于Modbus的电机控制上位机程序——用Qt打造高效控制界面
vscode
韩曙亮31 分钟前
【VSCode】设置中文、多标签设置 ( 设置显示语言 | 批量打开标签 | 标签栏切换 )
ide·vscode·编辑器·开发工具
Teln_小凯35 分钟前
解决VSCode 安装PlatformIO后,第一次创建项目很慢的问题
ide·vscode·编辑器
要加油哦~2 小时前
工具 | vscode 中出现的报错 | 橙色的提示和红色的波浪线代表?| ESLint 和 Prettier 规范问题
ide·vscode·编辑器
三天不学习12 小时前
Cursor vs Trae vs VSCode:2025终极IDE横评,谁才是开发者的效率之选?
ide·vscode·编辑器
一苓二肆15 小时前
代码常用工具使用
git·vscode·docker·github·vim
jimy120 小时前
切换、退出GitHub account with Copilot,github copilot账号,自动补全没额度了
vscode·copilot
试着21 小时前
【VSCode+AI+测试】连接ai大模型
ide·人工智能·vscode·python·学习·编辑器·ai-test
白里透白的小白1 天前
复盘 Git+GitHub SSH 配置:从权限报错到免密推送的全流程解决方案
git·ssh·github·版本控制
水木姚姚1 天前
VSCode 调试 C++ 之 cin 输入
c++·windows·vscode·开发工具·调试