本教程基于群晖(DSM7.2)的docker套件,其他docker正常情况下也可运行(可自行尝试)
1、Debian12镜像下载
打开docker,在注册表搜索Debian,右击选择下载此映像,点击应用下载。(我目前laster标签为Debian12(bookworm))
2、配置Debian
1、运行映像创建容器
注意端口设置开放22端口!!!后面ssh要用到,不需要ssh可不管 比如我映射为2222(可为任意无占用端口)
2、切换国内清华源和配置ssh
进入刚刚创建的容器打开终端机
同步系统上的软件包列表并安装vim apt-transport-https ca-certificates,其中apt-transport-https ca-certificates是解决无法拉取 HTTPS 源的情况。(官方源速度有点慢,可考虑仅安装vim后仅用HTTP源)
apt update && apt install apt-transport-https ca-certificates vim -y
运行vim /etc/apt/sources.list修改软件源,按键盘i进行修改,将下方链接复制进去后按ESC,输入英文冒号:后输入wq并回车保存
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
再运行以下代码更新软件包列表并安装ssh
apt update && apt install openssh-server -y
运行passwd修改root密码,使用vim修改sshd_config
vim /etc/ssh/sshd_config
将PermitRootLogin的值改为yes,/搜索即可,如没有自行添加 PermitRootLogin yes (PasswordAuthentication yes 不想用root用户登录添加这个,仅添加这个无法使用root登录)
#启动ssh服务
service ssh start
设置开机自启动ssh,采用了使用开机脚本/root/.bashrc
vim /root/.bashrc
在bashrc的启动文件的末尾,增加一条service ssh start
3、用ssh链接Debian
用FinalShell(看个人喜好,可以用其他软件)新建ssh连接,名称收随意,主机填群晖的地址,端口填上方映射的端口,用户名填root,密码填上方修改的密码。
至此,可以愉快的玩Debian了