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
相关推荐
SweerItTer11 小时前
由镜像源配置错误导致的软件包依赖问题
linux·vscode·ubuntu
冼紫菜12 小时前
如何在 CentOS 7 虚拟机上配置静态 IP 地址并保持重启后 SSH 连接
linux·开发语言·centos·ssh
海染棠花13 小时前
vscode+platformIO开发STM32(八)
ide·vscode·stm32
公子无缘14 小时前
【嵌入式】记一次解决VScode+PlatformIO安装卡死的经历
vscode·stm32·单片机·mcu·platformio
安装虚拟机的老师傅15 小时前
【2025最新】Windows系统装VSCode搭建C/C++开发环境(附带所有安装包)
c语言·windows·vscode·其他
妄想成为master21 小时前
拒绝flash插件打劫!如何在vscode上玩4399小游戏
vscode·扩展·4399·4399小游戏
czhc11400756631 天前
Linux513 rsync本地传输 跨设备传输 一
ssh
Willis_m1 天前
Linux 服务器用 SSH 拉取多个 Git 工程
linux·服务器·git·ssh
AI视觉网奇2 天前
vscode 默认环境路径
ide·vscode·编辑器
胖大和尚2 天前
Termius ssh连接服务器 vim打开的文件无法复制问题
服务器·ssh·vim