提示:Windows用户可使用 PuTTY 或 Windows Terminal + WSL 进行SSH连接。
三、基础系统配置(Debian)
1、更新系统
bash
apt update && apt upgrade -y
2、设置时区
bash
dpkg-reconfigure tzdata
选择你所在的时区(如 Asia/Shanghai)。
3、创建普通用户(安全建议)
bash
adduser yourusername
添加到sudo组:
bash
usermod -aG sudo yourusername
4、禁用root登录(可选,增强安全)
编辑SSH配置文件:
bash
nano /etc/ssh/sshd_config
修改以下行:
PermitRootLogin no
重启SSH服务:
bash
systemctl restart ssh
之后使用普通用户登录,必要时用 `sudo` 提权。
四、配置防火墙(UFW)
安装UFW:
bash
apt install ufw -y
允许SSH(默认端口22):
bash
ufw allow ssh
启用防火墙:
bash
ufw enable
查看状态:
bash
ufw status
五、更换APT源(国内用户推荐)
编辑源列表:
bash
nano /etc/apt/sources.list
替换为国内镜像源,例如阿里云:
deb http://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware
deb-src http://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware
deb http://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src http://mirrors.aliyun.com/debian-security/ bookworm-security main
deb http://mirrors.aliyun.com/debian/ bookworm-updates main
deb-src http://mirrors.aliyun.com/debian/ bookworm-updates main