Debian From Scratch 远程管理实操指南
一、总体思路与准备
ip addr 查看 IP,确保管理网段可达。二、SSH 远程管理(首选)
sudo apt update && sudo apt install openssh-serversudo systemctl start ssh && sudo systemctl enable sshsudo systemctl status ssh(应显示 active (running))sudo cp /etc/ssh/sshd_config{,.bak})
sudo nano /etc/ssh/sshd_configPort 2222(可选,避免默认端口 22)PermitRootLogin noPasswordAuthentication no(在部署好密钥后再关闭)AllowUsers your_username(仅允许指定用户)sudo systemctl restart sshsudo ufw allow 2222/tcp,随后 sudo ufw enablessh-keygen -t ed25519(或 ssh-keygen -t rsa -b 4096)ssh-copy-id -p 2222 your_username@server_ipssh -p 2222 your_username@server_ipssh -v -p 2222 your_username@server_ip三、Web 控制台与图形化远程
sudo apt update && sudo apt install cockpit,然后 sudo systemctl start cockpit && sudo systemctl enable cockpithttps://<server_ip>:9090(首次使用需为系统账户设置 Cockpit 登录)sudo apt install xrdp,然后 sudo systemctl enable xrdp && sudo systemctl start xrdpsudo apt install tightvncserver,执行 vncserver :1 设置访问密码<server_ip>:5901(对应显示号 :1)ssh -L 9090:localhost:9090 -L 5901:localhost:5901 user@server_ip,然后本地访问 https://localhost:9090 与 localhost:5901。四、自动化与第三方工具
五、安全与运维要点
AllowUsers)。sudo apt update && sudo apt upgradesudo 进行特权操作,保留命令历史以便审计。