在iptables中允许SFTP

我刚刚从林德购买了VPS,并正在通过设置指南。 我有一切运行(apache2,php,mysql等),但我被拒绝通过SFTP访问使用fileZilla上传文件时。

现在,这是我第二次安装服务器,因为我第一次错过了一个部分。 我第一次能够通过filezilla上的SFTP连接到我的服务器,而我错过的是添加一个新用户并在防火墙中编辑iptables

所以看起来,我一直在关注的指南阻止了SFTP,但允许SSH。

这是iptables文件:

*filter # Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0 -A INPUT -i lo -j ACCEPT -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT # Accept all established inbound connections -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Allow all outbound traffic - you can modify this to only allow certain traffic -A OUTPUT -j ACCEPT # Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL). -A INPUT -p tcp --dport 80 -j ACCEPT -A INPUT -p tcp --dport 443 -j ACCEPT # Allow SSH connections # # The -dport number should be the same port number you set in sshd_config # -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT # Allow ping -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT # Log iptables denied calls -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7 # Reject all other inbound - default deny unless explicitly allowed policy -A INPUT -j REJECT -A FORWARD -j REJECT COMMIT 

所有我想要的是我需要放在那里允许通过端口22的SFTP线路。

谢谢您阅读此篇。

你的/ etc / ssh / sshd_config必须包含

  Subsystem sftp /usr/lib/ssh/sftp-server 

能够SFTP。 如果没有,你可以SSH而不是SFTP。