确保Ubuntu服务器上已安装并启动SSH服务(SFTP依赖SSH)或FTP服务(如vsftpd)。
sudo systemctl status ssh,若显示active (running)则表示运行正常;若未运行,执行sudo systemctl start ssh启动,并用sudo systemctl enable ssh设置开机自启。sudo apt install vsftpd安装;启动服务sudo systemctl start vsftpd,并设置开机自启sudo systemctl enable vsftpd。Ubuntu默认使用ufw防火墙,需允许FTP(端口21)或SSH(端口22)流量:
sudo ufw allow 22/tcpsudo ufw allow 21/tcpsudo ufw enablesudo ufw status(确认规则已添加)。打开FileZilla→站点管理器→新站点,检查以下设置:
在客户端电脑上执行ping <服务器IP>,若无法ping通,说明网络不通(需检查服务器IP、路由器设置或运营商网络);若能ping通,继续用telnet <服务器IP> 22(SFTP)或telnet <服务器IP> 21(FTP)测试端口连通性,若提示“Connection refused”,则服务器未开放对应端口。
/etc/ssh/sshd_config):sudo vim /etc/ssh/sshd_config打开文件,确保以下设置未被注释(若有则修改):PermitRootLogin yes(允许root登录,若需root权限)、PasswordAuthentication yes(允许密码认证)。修改后重启SSH:sudo systemctl restart ssh。/etc/vsftpd.conf,仅FTP协议):local_enable=YES(允许本地用户登录)、write_enable=YES(允许上传/修改文件)、chroot_local_user=YES(限制用户到自家目录,提升安全性)。修改后重启vsftpd:sudo systemctl restart vsftpd。sudo tail -f /var/log/auth.log(实时查看SSH连接日志);sudo tail -f /var/log/vsftpd.log(vsftpd的日志路径,若未开启需修改/etc/vsftpd.conf中的xferlog_enable=YES)。pasv_min_port和pasv_max_port(如pasv_min_port=60000、pasv_max_port=61000),并在防火墙中开放该端口范围。chmod 755 /path/to/directory)。setenforce 0临时关闭,或修改/etc/selinux/config)。