Curl to prompt a User Name and Password

curl username:password
wget username password
curl --netrc
curl username:password header
curlrc username password
curl username:$password php
curl password file
curl authentication without password

I have a password protect web folder on my site, I am fetching that folder on another domain using Curl, what I want is: when I try to open the URL it should ask me the user name and password, instead of asking it display the "Authorization Required".


If I try to access the "a" url it ask me for the user name password. Fine. but it doesn't ask me for the user name and password on "b" (using curl here).

Any Idea?

In Short: I want to make Curl ask for the User/Password prompt.


I am not sure, if it is possible or not? but if it's possible so please let me know how, otherwise I will close this as "Invalid"

Try the following like :

curl -su 'user' <url>

It should prompt password for the user

Curl to prompt a User Name and Password, Use the -u flag to include a username, and curl will prompt for a password: curl -u username You can also include the password in the  The format of the password file is (as per man curl ): machine <> login <username> password <password>. Note: Machine name must not include https:// or similar! Just the hostname. The words ' machine ', ' login ', and ' password ' are just keywords; the actual information is the stuff after those keywords.

for .htaccess style password protection, You can code the userid password as in:

curl -u userid:password http://.......

Using cURL with a username and password?, Problem We want to use curl to access the site that required http authentication. Solution curl -u username:password  Passwords are tricky and sensitive. Leaking a password can make someone other than you access the resources and the data otherwise protected. curl offers several ways to receive passwords from the user and then subsequently pass them on or use them to something else. The most basic curl authentication option is -u / --user. It accepts an argument that is the user name and password, colon separated.

-H 'Authorization: Basic user:pass' user:pass must be encoded in base64

Specify username and password for curl command (Example), It accepts an argument that is the user name and password, colon separated. without specifying the password, and then curl will instead prompt the user for it  curl is a solid and simple tool that allows transferring data from and to any server with command line using various protocols including HTTP. To use curl to access the site that required http authentication, need to use -u to pass username and password with a colon between them i.e. <username>:<password>.



curl -v --user myName:mySecret


curl -v -u myName:mySecret

(example for Minh Nguyen see

curl -v -su 'myName'

asks for the pw of user 'myName'.

Passwords, Are there accepted ways of doing this? If the site uses HTTP authentication, then curl will prompt for a password if you provide a user name with  curl-users. Prompt for username and password. This message:[ Message body] [ More options] Related messages:[ Next message][ Previous message][ Next in thread] [ Replies] From: Jacky Lam <>. Date: Tue, 12 Mar 2002 17:40:53 +0800. Hi,

you can use cookies there I think. The steps would be:

  1. If you try to curl "" with no cookies, it can return you a html login form.
  2. Your form's action would point to 2nd server and if the credentials were right, set the cookie there and return (redirect) to server 1.
  3. And if you curl again, you'd check the cookie on the other side and in this case, it could read that cookie and return you the admin page output instead.

Re: Prompting for password, Use the -u flag to include the user name, and curl prompts for the password: curl -​u username You can also include a  curl -u username:password Written by Rezigned. Update Notifications Off.

Use a cURL with a username and password?, Hi, I'm trying to get the job table using curl, but I can't seem to get it to work. I keep getting a 403 error. curl -u mapr:password -kd @json  Many Linux and Unix command line tools such as curl command, wget command, lynx command, and others; use the environment variable called http_proxy, https_proxy, ftp_proxy to find the proxy details. It allows you to connect text based session and applications via the proxy server with or without a userame/password. T his page shows how to

How to use curl with username and password?, Don't show passwords or user credentials on screen-shares! Sometimes If you run Windows, and use curl, you must name the file _netrc . From man curl:-u, --user <user:password> If you just give the user name (without entering a colon) curl will prompt for a password. Just pass them the keyboard (or a screen/tmux share) and have them type it in.

Do you use curl? Stop using -u. Please use curl -n and .netrc , However, instead of passing the password as a command line argument, having cURL directly prompt for a password is better, as discussed on  To do that, use the -u user:pass command line argument. If you skip the password (but leave the colon), then no password is set. If you also skip the colon, then curl prompts for the password. Set the Username and Password via the -u Argument

  • Why not just prompt for a login before using Curl?
  • hmm that would be cool, my second domain is hosted on a Plesk server, which doesn't allow me to have htaccess over there.. and secondly, may be I don't want to have any password file on my second domain or any scripting...
  • I tried this, and it just tells me that it can't resolve host "username".
  • I think this should be the accepted answer, worked for me.
  • hmm, that a correct approach but I want a Password Prompt, never want to enter the user name or password in a file hosted on my second domain
  • Not sure about your environment, if I do it in a shell script. It is something like. read -p "Userid: " userid ; read -s -p "Password: " passwd; curl -u $userid:$passwd http://......
  • We need a http Prompt here.. instead of hard coded user name and passwrd
  • Let me see if I understand this correctly, on the "b" site you want to access the "a" site on the server side? and you want the "b" to generate a password prompt on the client's browser? You need a CGI on the "b" site to do that.
  • If you use any of these methods (including read -s method and any tricks around this), your password can be found in the system, process table: /proc or using strace -p <pid>
  • That solution doesn't prompt for a password. You have the password on the curl command line.
  • Nopes, it doesn't return the login prompt.. that what I needed!
  • Ok but you need to write it yourself. using php or whatever you got there.
  • This answer should NOT be accepted, where is the Answer? How do you place PHP_AUTH_USER? A sample with Code would be great for other users! This is just confusing even more!