共计 2546 个字符,预计需要花费 7 分钟才能阅读完成。
VPS 虚拟服务器 DD 任何系统 最安全的办法,感谢 KDE 大佬提供技术支持。
1 任何 linux 系统先 dd 成 debian 11
1.1 一般 vps 用这个脚本就行了,用户名“root”,密码“https://hostloc.com/”,端口“2222”
bash <(wget –no-check-certificate -qO- ‘https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh’) -d 11 -v 64 -p “https://hostloc.com/” -port “2222”
1.2 比如谷歌云之类的内网 IP 的,需要指定内网地址,内网掩码,内网网关。用户名“root”,密码“https://hostloc.com/”,端口“2222”
bash <(wget –no-check-certificate -qO- ‘https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh’) –ip-addr 10.0.0.2 –ip-gate 10.0.0.1 –ip-mask 255.255.255.0 -d 11 -v 64 -p “https://hostloc.com/” -port “2222”
2 DD 成 debian 11 系统之后(通过脚本 DD 的,不知道有没有后门,就当它有后门吧),再运行内存救援系统 mfslinux(基于 openwrt)
# 更新包列表
apt update
# 安装必备的软件包
apt install -y grub2 grub-imageboot
# 创建 iso 文件夹目录
mkdir -p /boot/images/
# 下载 mfslinux 内存救援系统
wget –no-check-certificate -O /boot/images/mfslinux.iso https://mfsbsd.vx.sk/files/iso/mfslinux/mfslinux-0.1.10-f9c75a4.iso
# 设置 GRUB 开机启动为 mfslinux
sed -i ‘s/GRUB_DEFAULT=0/GRUB_DEFAULT=2/g’ /etc/default/grub
# 重新生成 grub
update-grub2
# 重启进入 mfslinux
reboot
默认用户“root”
默认密码“mfslinux”
默认端口“22”
3 进入内存救援系统之后安装必备的软件包
3.1 安装必备软件包
# 更新包列表
opkg update
# 安装进度显示 pv 包
opkg install pv
# 安装必备的 gzip 包
opkg install gzip
# 安装 dd 完整功能包
opkg install coreutils-dd
4 DD 任何基于 raw/img 原始镜像系统,包括压缩为 zip、gz、xz……格式的。
4.1 DD 官方 Debian 11 云镜像系统 raw/img 原始镜像
wget -O- “https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.raw” | pv | dd of=/dev/ 实际硬盘位置 bs=4M oflag=sync
4.2 DD raw/img 镜像压缩为 zip/gz 格式的系统
wget -O- https://download.mikrotik.com/routeros/7.3beta37/chr-7.3beta37.img.zip | pv | zcat | dd of=/dev/ 实际硬盘位置 bs=4M oflag=sync
4.3 运行 lsblk 查看判断实际硬盘位置
4.4 有些云镜像只有 qcow2 格式,需要转成 raw 才能 DD,为了提高效率,可以压缩为 zip/gz 格式的!弄个小鸡开 nginx 提供 http 下载
qemu-img convert -f qcow2 -O raw image.qcow2 image.raw
5 修改云镜像的密码
5.1 DD 完之后,挂载硬盘,打开系统所在分区的 /etc/ 目录
mount /dev/sda1 /mnt
硬盘位置和系统所在分区以实际为准!
运行 lsblk 查看判断
5.2 获取密码
[root@r ~]# openssl passwd -1 https://hostloc.com/
$1$1UVdmoQe$MKwgVugqOmLxeSo7q7lLo1
5.3 设置 root 密码为“https://hostloc.com/”
nano /mnt/etc/shadow
root:$1$1UVdmoQe$MKwgVugqOmLxeSo7q7lLo1:18849:0:99999:7:::
6 修改 ssh 允许 root 登录、允许密码登录
nano /mnt/etc/ssh/sshd_congfig
找到下面这两项改成 yes,其他的不要改。如果有相同启用了的选项在前面加 #
PermitRootLogin yes
PasswordAuthentication yes
至此全部完成!
感谢 @zxxx 分享 mfslinux 内存救援系统
https://hostloc.com/thread-1004553-1-1.html
感谢秋水逸冰
https://teddysun.com/629.html
附录云镜像列表
RHEL # 需要注册开发者账户使用一年 qcow2 类型 可以谷歌搜索下 关键词“redhat 开发者注册试用”
https://access.redhat.com/downloads/content/486/ver=/rhel—9/9.0%20Beta/x86_64/product-software
CentOS Stream # RHEL 上游 就是把新内核 新驱动 新包 新功能 放 CentOS Stream 测试 没问题了 再出 RHEL 稳定版
https://cloud.centos.org/centos/9-stream/x86_64/images/
Debian 11 # deb 系王者 自由的 没商业支持
https://cloud.debian.org/images/cloud/bullseye/latest/
Ubuntu # deb 系商业化的 有商业支持 教程多 大部分开发者都用这个
https://cloud-images.ubuntu.com/releases/