在配置Debian系统以支持SFTP(SSH File Transfer Protocol)时,需要注意以下几个关键点:
安装SSH服务器:
sudo apt update
sudo apt install openssh-server
配置SSH服务器:
/etc/ssh/sshd_config:sudo nano /etc/ssh/sshd_config
Port 22 # 默认端口,可以根据需要更改
PermitRootLogin no # 不允许root用户直接登录
PasswordAuthentication yes # 允许密码认证(也可以使用公钥认证)
AllowUsers your_username # 允许特定用户登录
Subsystem sftp internal-sftp # 启用SFTP子系统
重启SSH服务:
sudo systemctl restart sshd
配置防火墙:
sudo ufw allow 22
sudo ufw enable
用户权限和目录设置:
sudo chown root:root /home/your_username
sudo chmod 755 /home/your_username
sudo mkdir /home/your_username/sftp
sudo chown your_username:your_username /home/your_username/sftp
sudo chmod 755 /home/your_username/sftp
SELinux/AppArmor(如果适用):
日志监控:
sudo tail -f /var/log/auth.log
安全性考虑:
通过以上步骤,你可以确保Debian系统上的SFTP配置既安全又可靠。