Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am experiencing very strange behavior with IIS FTP 7.5 on Windows 2008 Server R2 and a python 2.7.3 ftp module I am writing. The module does a ftp connect with the FTP_TLS library in FTP Active mode and a simple file write to the server.

I have setup a fresh install of 2008 R2 with FTP services and generated a Self Signed certificate per the instructions :

http://www.iis.net/learn/publish/using-the-ftp-service/using-ftp-over-ssl-in-iis-7

http://www.iis.net/learn/publish/using-the-ftp-service/configuring-ftp-firewall-settings-in-iis-7

I am able to connect, login, change directories, list files and put files without issue using my Python module... However, as soon as I change the connection to prot_p (encrypted data channel) I am unable to transfer files. I never receive a 226 file transferred successfull response from the server and it finally times out. The file is created on the FTP host with 0 bytes and if I manually kill the client side the file disappears.

I have setup a Filezilla server on the same windows server with FTPes and a self signed certificate in Active mode with forced SSL authentication and Data transfer and the same Python module has no issues with putting files.

I have run wireshark but since it is encrypted traffic the last transmission during the file write that hangs is not readable as far as I can tell.

Here is my Python code :

#!/usr/local/bin/python
#imports
from ftplib import FTP
from ftplib import FTP_TLS
import ssl
import os
import fnmatch
import sys
import time

#connect to FTP host
ftp = FTP_TLS()

#establish secure channels
ftp.auth()            # force secure control connection
ftp.prot_p()          # switch to secure data connection

vshost="192.168.1.10"
vsport="21"

try:    
  ftp.connect(host=vshost,port=vsport)
  print "Successfully connected to FTPes host " + vshost + " : " + vsport
except:
  print "Unable to connect to FTPes host " + vshost + " : " + vsport
  exit(1)


ftp.set_pasv(0)       # FTP Active mode enabled
print "FTP Active Mode Enabled"

username="test"
password="test"

try:
  ftp.login(username,password)
  print "FTP Login successful"
except:
  print "Unable to login"
  ftp.quit()
  exit(1)

ftppath="/"
try:
  ftp.cwd(ftppath)
except:
  print "Could not cwd to: " + ftppath
  ftp.quit()
  exit(1)

try:
  ftp.pwd()
except:
  print "Could not list current directory"
  ftp.quit()
  exit(1)

try:
  f = open('C:\Users\Jeremy\Desktop\test1.txt', 'r')
  filename="test1.txt"
  try:
    ftp.storlines("STOR " + filename, f)
    f.close()
    print "Successful Upload!"
  except:
    print "Error in uploading the remote file."
    raise

  #politely exit the ftp server
  ftp.quit()

  print "Ftp has finished uploading all files successfully."
  exit(0)

except:
  print "Ftp has finished with ERRORS."
  exit(1)

Any help is greatly appreciated.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.