Reputation: 688
I writing simple uploading script and just catched next thing: curl tries to do PUT on a ftp server:
The simplified code:
import pycurl
from os.path import getsize
c = pycurl.Curl()
c.setopt(pycurl.URL, 'ftp://<ftp_name>:21/asus.c')
c.setopt(pycurl.USERPWD, 'username:password')
c.setopt(pycurl.PROXY, '10.0.0.35')
c.setopt(pycurl.PROXYPORT, 3128)
c.setopt(pycurl.VERBOSE, 1)
f = open('asus.c')
c.setopt(pycurl.INFILE, f)
c.setopt(pycurl.INFILESIZE, getsize('asus.c'))
c.setopt(pycurl.HTTPPROXYTUNNEL, 1)
c.setopt(pycurl.UPLOAD, 1)
c.perform()
Almost same code worked well few month ago, but:
* About to connect() to proxy <IP> port 3128 (#0)
* Trying <IP>... * connected
* Connected to <IP> (<IP>) port 3128 (#0)
* Establish HTTP proxy tunnel to <ftp_name>:21
* Server auth using Basic with user 'username'
> CONNECT <ftp_name>:21 HTTP/1.1
Host: <ftp_name>:21
User-Agent: PycURL/7.21.6
Proxy-Connection: Keep-Alive
< HTTP/1.0 200 Connection established
<
* Proxy replied OK to CONNECT request
* Server auth using Basic with user 'username'
> PUT /asus.c HTTP/1.1
Authorization: Basic _______________________________
User-Agent: PycURL/7.21.6
Host: <ftp_name>:21
Accept: */*
Content-Length: 2627
Expect: 100-continue
220 ProFTPD 1.3.3 Server (______ FTP Server) [<IP>]
500 PUT not understood
500 AUTHORIZATION: not understood
500 USER-AGENT: not understood
500 HOST: not understood
500 ACCEPT: not understood
500 CONTENT-LENGTH: not understood
500 EXPECT: not understood
500 Invalid command: try being more creative
And same response when I try to do this from shell:
curl --upload-file "asus.c" --proxy 10.0.0.35:3128 \
--proxytunnel -u username:password ftp://<ftp_name>/asus.c
Why? What I missed?
Upvotes: 3
Views: 14723
Reputation: 797
Here is the format working for me.
curl --user 'ftp_user:ftp_password' --disable-epsv --proxytunnel -x 'yourproxy.com:port' -T 'your.localfile' 'ftp://remote.ftp.org:port/path' -v
I spent a lot of time to struggle with those parameters, let me know if you have curl as ftp problem.
Here is some parameter related:
-U or --proxy-user <proxy_user:proxy_password>
if you need proxy credential
-u or --user <ftp_user:ftp_password>
if you have remote ftp username and password
--proxy-digest
if your proxy use digest authentication
--proxy-basic
if your proxy use basic authentication
--proxy-anyauth
if you want to detech proxy authentication
-l or --list-only
if you only want to list an FTP directory.
--digest
remote ftp using digest authentication
--basic
remote ftp using basic authentication
-3 or --sslv3
(SSL) Forces curl to use SSL version 3 when connect with remote ssl server
-p or --proxytunnel
if you have -x or --proxy
this option will cause non-http protocols to attempt to tunnel through the proxy instead of merely using it to do http-like operations.
-v or --verbose
if you need verbose
--ftp-ssl
Upvotes: 2
Reputation: 9655
The syntax for ftp upload is:
curl -u "[email protected] Proxy-Username:Remote-Pass" --ftp-account Proxy-Password --upload-file local-file ftp://my-ftp.proxy.server:21/remote/upload/path/
Upvotes: 0