You always find news about what's going on as well as the latest versions
from the curl web pages, located at:
- http://curl.haxx.se
+ https://curl.haxx.se
SIMPLE USAGE
Get a file from an SSH server using SFTP:
- curl -u username sftp://shell.example.com/etc/issue
+ curl -u username sftp://example.com/etc/issue
- Get a file from an SSH server using SCP using a private key to authenticate:
+ Get a file from an SSH server using SCP using a private key
+ (not password-protected) to authenticate:
- curl -u username: --key ~/.ssh/id_dsa --pubkey ~/.ssh/id_dsa.pub \
- scp://shell.example.com/~/personal.txt
+ curl -u username: --key ~/.ssh/id_rsa \
+ scp://example.com/~/file.txt
+
+ Get a file from an SSH server using SCP using a private key
+ (password-protected) to authenticate:
+
+ curl -u username: --key ~/.ssh/id_rsa --pass private_key_password \
+ scp://example.com/~/file.txt
Get the main page from an IPv6 web server:
curl "http://[2001:1890:1112:1::20]/"
+ Get a file from an SMB server:
+
+ curl -u "domain\username:passwd" smb://server.example.com/share/file.txt
+
DOWNLOAD TO A FILE
Get a web page and store in a local file with a specific name:
SFTP / SCP
- This is similar to FTP, but you can specify a private key to use instead of
- a password. Note that the private key may itself be protected by a password
- that is unrelated to the login password of the remote system. If you
- provide a private key file you must also provide a public key file.
+ This is similar to FTP, but you can use the --key option to specify a
+ private key to use instead of a password. Note that the private key may
+ itself be protected by a password that is unrelated to the login password
+ of the remote system; this password is specified using the --pass option.
+ Typically, curl will automatically extract the public key from the private
+ key file, but in cases where curl does not have the proper library support,
+ a matching public key file must be specified using the --pubkey option.
HTTP
curl -u name:passwd http://machine.domain/full/path/to/file
HTTP offers many different methods of authentication and curl supports
- several: Basic, Digest, NTLM and Negotiate. Without telling which method to
- use, curl defaults to Basic. You can also ask curl to pick the most secure
- ones out of the ones that the server accepts for the given URL, by using
- --anyauth.
+ several: Basic, Digest, NTLM and Negotiate (SPNEGO). Without telling which
+ method to use, curl defaults to Basic. You can also ask curl to pick the
+ most secure ones out of the ones that the server accepts for the given URL,
+ by using --anyauth.
NOTE! According to the URL specification, HTTP URLs can not contain a user
and password, so that style will not work when using curl via a proxy, even
curl --proxytunnel -x proxy:port -T localfile ftp.upload.com
+SMB / SMBS
+
+ curl -T file.txt -u "domain\username:passwd"
+ smb://server.example.com/share/
+
HTTP
Upload all data on stdin to a specified HTTP site:
How to post a form with curl, lesson #1:
- Dig out all the <input> tags in the form that you want to fill in. (There's
- a perl program called formfind.pl on the curl site that helps with this).
+ Dig out all the <input> tags in the form that you want to fill in.
If there's a "normal" post, you use -d to post. -d takes a full "post
string", which is in the format
stored cookies which match the request as it follows the location. The
file "empty.txt" may be a nonexistent file.
- Alas, to both read and write cookies from a netscape cookie file, you can
- set both -b and -c to use the same file:
+ To read and write cookies from a netscape cookie file, you can set both -b
+ and -c to use the same file:
curl -b cookies.txt -c cookies.txt www.example.com
If you have installed the OpenLDAP library, curl can take advantage of it
and offer ldap:// support.
+ On Windows, curl will use WinLDAP from Platform SDK by default.
- LDAP is a complex thing and writing an LDAP query is not an easy task. I do
- advise you to dig up the syntax description for that elsewhere. Two places
- that might suit you are:
+ Default protocol version used by curl is LDAPv3. LDAPv2 will be used as
+ fallback mechanism in case if LDAPv3 will fail to connect.
- Netscape's "Netscape Directory SDK 3.0 for C Programmer's Guide Chapter 10:
- Working with LDAP URLs":
- http://developer.netscape.com/docs/manuals/dirsdk/csdk30/url.htm
+ LDAP is a complex thing and writing an LDAP query is not an easy task. I do
+ advise you to dig up the syntax description for that elsewhere. One such
+ place might be:
- RFC 2255, "The LDAP URL Format" http://curl.haxx.se/rfc/rfc2255.txt
+ RFC 2255, "The LDAP URL Format" https://curl.haxx.se/rfc/rfc2255.txt
To show you an example, this is how I can get all people from my local LDAP
server that has a certain sub-domain in their email address:
If I want the same info in HTML format, I can get it by not using the -B
(enforce ASCII) flag.
+ You also can use authentication when accessing LDAP catalog:
+
+ curl -u user:passwd "ldap://ldap.frontec.se/o=frontec??sub?mail=*"
+ curl "ldap://user:passwd@ldap.frontec.se/o=frontec??sub?mail=*"
+
+ By default, if user and password provided, OpenLDAP/WinLDAP will use basic
+ authentication. On Windows you can control this behavior by providing
+ one of --basic, --ntlm or --digest option in curl command line
+
+ curl --ntlm "ldap://user:passwd@ldap.frontec.se/o=frontec??sub?mail=*"
+
+ On Windows, if no user/password specified, auto-negotiation mechanism will
+ be used with current logon credentials (SSPI/SPNEGO).
+
ENVIRONMENT VARIABLES
Curl reads and understands the following environment variables:
If the host name matches one of these strings, or the host is within the
domain of one of these strings, transactions with that node will not be
- proxied.
-
+ proxied. When a domain is used, it needs to start with a period. A user can
+ specify that both www.example.com and foo.example.com should not uses a
+ proxy by setting NO_PROXY to ".example.com". By including the full name you
+ can exclude specific host names, so to make www.example.com not use a proxy
+ but still have foo.example.com do it, set NO_PROXY to "www.example.com"
The usage of the -x/--proxy flag overrides the environment variables.
For your convenience, we have several open mailing lists to discuss curl,
its development and things relevant to this. Get all info at
- http://curl.haxx.se/mail/. Some of the lists available are:
+ https://curl.haxx.se/mail/. Some of the lists available are:
curl-users