前置条件
基于debian12官网的qcow2格式文件进行操作
安装ssh
登录虚拟机后安装ssh服务端
apt install openssh-server
配置国内源
新增/etc/apt/sources.list.d/tsinghua.list
使用清华大学的源
https://www.cnblogs.com/shanhubei/p/18104430
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
扩容
系统盘只有2G,需要扩下
虚拟机虚拟介质扩容量
先在virtualbox中对系统盘扩容到10G
linux系统内部扩容
1、下载parted命令
2、扩容
参考https://blog.youkuaiyun.com/qq_45664055/article/details/137920769
parted输入后使用resizepart 命令进行扩
3、调整文件系统
ext4的使用resize2fs
resize2fs /dev/sda1
4、使用df -h命令查看发现已经扩容OK了
设置时区
root用户下执行
timedatectl set-timezone 'Asia/Shanghai'
编辑颜色
编辑~/.bashrc
放开以下几行的注释后重新登录即可。
export LS_OPTIONS='--color=auto'
eval "$(dircolors)"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
粘贴
在ssh下vi右击鼠标会进入 insert visual模式,可以通过以下命令操作后正常右击粘贴
命令模式下输入
set mouse-=a
scp指定端口
scp -P 232 nexus-3.76.0-03-unix.tar.gz xx@127.0.0.1:~/
防火墙配置
推荐方案
1. 安装工具
sudo apt update
sudo apt install iptables-persistent
2. 保存当前规则
IPv4 规则:
sudo iptables-save > /etc/iptables/rules.v4
IPv6 规则(可选):
sudo ip6tables-save > /etc/iptables/rules.v6
启用持久化服务
sudo systemctl enable netfilter-persistent
验证服务状态
sudo systemctl status netfilter-persistent
确保服务处于 active (exited) 状态。
# 此命令将当前活动的 iptables 规则保存到 /etc/iptables/rules.v4(IPv4)和 /etc/iptables/rules.v6(IPv6)
netfilter-persistent save
5. 更新规则
修改防火墙规则后重新保存:
sudo iptables-save > /etc/iptables/rules.v4
# 可选:sudo ip6tables-save > /etc/iptables/rules.v6