Debian 新系统简易快速设置
新装 Debian 系统后的一些常用设置,记录下来方便下次直接用。
常用工具一键安装
apt install -y --no-install-recommends \
bind9-dnsutils binutils bzip2 curl git jq \
nginx libnginx-mod-http-headers-more-filter \
snmpd unzip wget xz-utils
允许 Root 用户 SSH 登录
cat /etc/ssh/sshd_config | grep -Eq "^[# ]?PermitRootLogin " ; \
[ $? -eq 0 ] && sed -i 's/^[# ]\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config \
|| echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config
启用密码认证
cat /etc/ssh/sshd_config | grep -Eq "^[# ]?PasswordAuthentication " ; \
[ $? -eq 0 ] && sed -i 's/^[# ]\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config \
|| echo -e "\nPasswordAuthentication yes" >> /etc/ssh/sshd_config
启动 SSH 服务
ps -ef | grep -q ssh ; \
[ $? -eq 0 ] && systemctl restart sshd || systemctl enable --now sshd
时区设置
dpkg-reconfigure tzdata
替换清华源
编辑 /etc/apt/sources.list:
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
Docker 安装
apt-get update && apt-get upgrade -y
curl -sSL https://linuxmirrors.cn/docker.sh | bash