提醒:本文最后更新于 2025-02-16 19:07,文中所关联的信息可能已发生改变,请知悉!
甲骨文 AMD & ARM 救砖教程
挂载折腾坏了的实例的引导卷到同账号其他甲骨文实例。
执行 lsblk 看看挂载的卷设备名,一般是 sdb,
1.1 救砖甲骨文 AMD 执行
curl -Lo- "https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-amd64.tar.xz" | tar -xJO | dd of=/dev/sdb bs=1M
如果需要 Debian 12 系统,则执行
curl -Lo- "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.tar.xz" | tar -xJO | dd of=/dev/sdb bs=1M
1.2 救砖 甲骨文 ARM 执行
curl -Lo- "https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-arm64.tar.xz" | tar -xJO | dd of=/dev/sdb bs=1M
如果需要 Debian 12 系统,则执行
curl -Lo- "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.tar.xz" | tar -xJO | dd of=/dev/sdb bs=1M
DD 过程大约 2.5 分钟。
2 完成后分离卷挂载回原实例。
启动实例。
3 点击“控制台连接”下级菜单的 启动“Cloud Shell 连接”。
强制重启实例。
看到实例启动后,使用用户名 root 密码空登录实例。
用命令 passwd 设置 root 密码。
cat << 'EOF' > setup_ssh_custom_port.sh
#!/bin/bash
# Prompt user to set root password
read -p "Do you want to set the root password? (y/n, default: n)" set_root_password
set_root_password=${set_root_password:-n}
if ["$set_root_password" == "y"]; then
echo "Please enter the new root password:"
read -s root_password
# Set root password
echo "root:$root_password" | sudo chpasswd
echo "Root password has been set."
fi
# Update package list
echo "Updating package list..."
sudo apt update -q >/dev/null 2>&1
# Install SSH (quiet mode)
echo "Installing SSH..."
sudo apt install -y -q openssh-server >/dev/null 2>&1
# Start SSH service and enable it to start on boot
sudo systemctl start ssh
sudo systemctl enable ssh >/dev/null 2>&1
# Prompt user to change SSH port
read -p "Do you want to set a custom SSH port? (y/n, default: n)" set_ssh_port
set_ssh_port=${set_ssh_port:-n}
if ["$set_ssh_port" == "y"]; then
echo "Please enter the custom SSH port:"
read ssh_port
# Change SSH configuration to use custom port
sudo sed -i "s/#Port 22/Port $ssh_port/" /etc/ssh/sshd_config
# Update firewall settings to allow custom SSH port
sudo ufw allow $ssh_port/tcp
echo "SSH port has been set to $ssh_port."
fi
# Permit root login and enable password authentication
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
# Restart SSH service
sudo systemctl restart ssh
echo "SSH installation and configuration complete. Please be aware of the security risks."
EOF
bash setup_ssh_custom_port.sh
至此服务器已经可以远程 ssh 登录,救砖完成。
正文完