Can't connect to FTP site because server actively refused it but WinSCP works

2

1

I have a RedHat 7 server that a friend of mine setup, and he is no longer working here with us, so I have taken over. I can connect to the server and transfer files via WinSCP but I cannot connect to it via the Python script that I wrote. I get the message "failed to connect because the server actively refused it".

After digging around a bit, I did not see anything in the iptables file. It is literally empty, and I don't see any evidence of VSFTPD installed. I was however able to access the firewall setting via GUI and tried playing around with ports with no luck.

I am wondering if the reason its not working via Python is because there is no FTP transfer program installed? Please advise as I am intermediate with my skills in Linux and I am trying to figure this thing out!

RickwhoPrograms

Posted 2018-06-08T14:09:52.200

Reputation: 148

Are you running WinSCP and Python script on the same machine? Post WinSCP log file as well as your Python code. – Martin Prikryl – 2018-06-08T14:58:15.673

I think I got it, The reason was that the sever had no config file for ftp, SFTP is working just fine, but python ftplib doesnt support a method of connecting via SFTP – RickwhoPrograms – 2018-06-08T15:10:51.070

I'm going to use this information to keep researching python and ftp config! – RickwhoPrograms – 2018-06-08T15:24:10.997

SCP, SFTP and FTP are three different protocols. The former two are somewhat related (by their relation to SSH), yet still different. – Kamil Maciorowski – 2018-06-08T15:28:24.473

Yes, I knew that, I just did not realize that python's FTPLIB library didnt support SFTP, but I found an interesting issue here, and now I can have fun engineering around it to continue messing with the capabilities of both server and python! – RickwhoPrograms – 2018-06-08T15:31:04.730

Also very interesting because I know a lot of users struggle with server actively refusing things, This will be a great find to shed some light on potential reasons behind the cause of this error – RickwhoPrograms – 2018-06-08T15:32:00.687

Answers

1

As you have found out, in WinSCP you are using SFTP. While ftplib is, as the name says, an FTP library.

For SFTP in Python, use Paramiko library.

Martin Prikryl

Posted 2018-06-08T14:09:52.200

Reputation: 13 764

Thanks for your support Martin, I did find Paramiko after some further investigation! – RickwhoPrograms – 2018-06-08T17:45:25.173