本文以Windows Hyper-V为例,记录Debian12虚拟机及设置ssh登录,静态IP等步骤

虚拟机安装

  • 使用第二代虚拟机

  • 安全启动取消勾选

设置ssh登录

编辑 /etc/ssh/sshd_config 文件,设置允许root登录,使用密钥登录

PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile	.ssh/authorized_keys .ssh/authorized_keys2

设置静态IP

编辑 /etc/network/interfaces 文件,添加末尾的一段,把上边的dhcp注释掉

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp
# This is an autoconfigured IPv6 interface
#iface eth0 inet6 auto

auto eth0
iface eth0 inet static
address 192.168.2.11
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1 114.114.114.114

设置国内镜像源

编辑 /etc/apt/sources.list 文件,把原来的内容注释掉,替换成下方的阿里源

deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib