Hi, I having a problem connect via FTP, Error said

Status: Connecting to 178.128.101.122
178.128.101.122…
Response: fzSftp started, protocol_version=9
Command: open “root@178.128.101.122
178.128.101.122” 22
Error: Could not connect to server

I have been able to connect before. but now I cant. Please help. Thank you.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi @tor9togethers,

You’ll need to make sure you have your IP whitelisted on your droplet and your port opened.

To do so, SSH to your droplet

ssh root@YourDropletIP

Then once you are in, open port to 21(FTP)

iptables -A INPUT -i eth0 -p tcp -m tcp --dport 21 -j ACCEPT

The above will allow the port for everyone. If you want to allow it only for your IP, run the following

iptables -A INPUT -p tcp -s XXX.XXX.XXX.XXX --sport 1024:65535 -d XXX.XXX.XXX.XXX --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s XXX.XXX.XXX.XXX --sport 21 -d XXX.XXX.XXX.XXX --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

Please remember to change XXX.XXX.XXX.XXX with your actual IP address.

Additionally, you might want to allow traffic to your droplet for every port from your IP address, you can achieve this by running the following commands

/sbin/iptables -A INPUT -p tcp -s XXX.XXX.XXX.XXX -j ACCEPT
/sbin/iptables -A OUTPUT -p tcp -d  XXX.XXX.XXX.XXX -j ACCEPT

Again, please remember to change XXX.XXX.XXX.XXX to the actual IP address.

Regards,
KDSys

Submit an Answer