Ruby



Ruby : Establish a connection to an FTP server via a proxy



Written by Anthony Heukmes on Wed Apr 08 12:17:03 UTC 2009

1 comment



By default, it's not possible to connect to an FTP server via a proxy using the Net::FTP Ruby library.
To use your proxy, you have to send RAW commands to the server :

@ftp = Net::FTP.new

@ftp.connect("proxy_address")
@ftp.sendcmd("USER ftp_login@ftp_address proxy_login")
@ftp.sendcmd("PASS ftp_password")
@ftp.sendcmd("ACCT proxy_password")
@ftp.passive = true


Take the time to replace addresses and credentials by yours.
This code considers that access to your proxy server is secured by login/password.