Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"cf login " interactive password prompt fails on cygwin #171

Closed
gberche-orange opened this issue May 15, 2014 · 40 comments
Closed

"cf login " interactive password prompt fails on cygwin #171

gberche-orange opened this issue May 15, 2014 · 40 comments

Comments

@gberche-orange
Copy link

password should be interactively prompted for when -p is omitted, regardless of whether -u was specified.

At least, it should be more user-friendly to remind users that if they prefer interactive login (to avoid having password recorded in their shell history) then they should omit both password and login, otherwise the password won't be prompted and auth will fail:

$ cf login -a https://api.run.pivotal.io -u user@domain.com -o myorg
API endpoint: https://api.run.pivotal.io
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
FAILED
Unable to authenticate.

API endpoint: https://api.run.pivotal.io (API version: 2.4.0)
Not logged in. Use 'cf.exe login' to log in.

$ cf --version
C:\Program Files (x86)\CloudFoundry\cf.exe version 6.1.2-6a013ca
@tjarratt
Copy link
Contributor

Hey Guillaume,

What you're describing sounds like a real bug I saw a few weeks ago on windows. Could you provide a little more information? Are you using cmd.exe, powershell or Cygwin?

Sent From A Very Small Keyboard

On May 15, 2014, at 8:03, Guillaume Berche notifications@github.com wrote:

password should be interactively prompted for when -p is omitted, regardless of whether -u was specified.

At least, it should be more user-friendly to remind users that if they prefer interactive login (to avoid having password recorded in their shell history) then they should omit both password and login, otherwise the password won't be prompted and auth will fail:

$ cf login -a https://api.run.pivotal.io -u user@domain.com -o myorg
API endpoint: https://api.run.pivotal.io
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
FAILED
Unable to authenticate.

API endpoint: https://api.run.pivotal.io (API version: 2.4.0)
Not logged in. Use 'cf.exe login' to log in.

$ cf --version
C:\Program Files (x86)\CloudFoundry\cf.exe version 6.1.2-6a013ca

Reply to this email directly or view it on GitHub.

@gberche-orange gberche-orange changed the title "cf login -u user" should prompt for pwd or reject arguments instead of retry-failing auth "cf login " interactive password prompt fails on cygwin May 15, 2014
@gberche-orange
Copy link
Author

You're right, it works properly with cmd.exe but fails within cygwin even if -u is not specified

$ cf login -a https://api.run.pivotal.io -o myorg
API endpoint: https://api.run.pivotal.io

Email> user@domain.com 
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
FAILED
Unable to authenticate.

API endpoint: https://api.run.pivotal.io (API version: 2.4.0)
Not logged in. Use 'cf.exe login' to log in.

I'm using cygin on win7

$ cygcheck.exe -V
cygcheck (cygwin) 1.7.27
System Checker for Cygwin
Copyright (C) 1998 - 2013 Red Hat, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I can send you privately the output of $ cygcheck.exe -s with full diags if this may help.

$ cygcheck.exe -s

Cygwin Configuration Diagnostics
Current System Time: Thu May 15 16:15:02 2014

Windows 7 Enterprise Ver 6.1 Build 7601 Service Pack 1
[...]

@tjarratt
Copy link
Contributor

Thanks for confirming. I don't know when this will be fixed, but it is a known bug.

For what it's worth, our supported clients on windows are powershell and cmd.exe

You can also use the 'cf auth' command to authenticate non-interactively.

Sent From A Very Small Keyboard

On May 15, 2014, at 8:18, Guillaume Berche notifications@github.com wrote:

You're right, it works properly with cmd.exe but fails within cygwin even if -u is not specified

$ cf login -a https://api.run.pivotal.io -o myorg
API endpoint: https://api.run.pivotal.io

Email> user@domain.com
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
Authenticating...
Credentials were rejected, please try again.
FAILED
Unable to authenticate.

API endpoint: https://api.run.pivotal.io (API version: 2.4.0)
Not logged in. Use 'cf.exe login' to log in.
I'm using cygin on win7

$ cygcheck.exe -V
cygcheck (cygwin) 1.7.27
System Checker for Cygwin
Copyright (C) 1998 - 2013 Red Hat, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I can send you privately the output of $ cygcheck.exe -s with full diags if this may help.

$ cygcheck.exe -s

Cygwin Configuration Diagnostics
Current System Time: Thu May 15 16:15:02 2014

Windows 7 Enterprise Ver 6.1 Build 7601 Service Pack 1
[...]

Reply to this email directly or view it on GitHub.

@lcddave lcddave added the bug label May 16, 2014
@mbhave
Copy link

mbhave commented May 16, 2014

@gberche-orange @tjarratt We are closing this issue for now because Cygwin is not supported currently. There is a story in the CLI tracker project for this feature which can be found here.

Thanks,
CF Community Pair (@mbhave, @stupakov)

@mbhave mbhave closed this as completed May 16, 2014
@tjarratt
Copy link
Contributor

Also it seems that cygwin is not currently a supported environment for Windows. A little surprising, but makes it easier to explain why this doesn't work.

@robdimsdale
Copy link
Member

+1 on this issue. Is cywgin still unsupported? Also, the tracker link is broken - was the story deleted?

@hagemt
Copy link

hagemt commented Jan 15, 2015

Another +1 here. As for the story, after sign-up, I get: "You are not allowed to view the requested page."

@hao5ang
Copy link

hao5ang commented Apr 18, 2015

+1

@maximilien
Copy link
Contributor

-1 for cygwin or windows...

I kid, I kid, of course. We <3 our Windows users. Cheers.

@gberche-orange
Copy link
Author

For windows users, a bash shell with productive features (searching in the history, clipboard cut/paste, completion on file path, alias to set CF_HOME to switch among CF instances...), makes a real difference in term of productivity when using the CF CLI.

I currently work around this issue using cf auth login pwd instead of cf login.

@dhudici
Copy link

dhudici commented Dec 11, 2015

+1

@michaellihs
Copy link

+1 for implementing Cygwin support or at least providing a workaround with the current "bug"

@quanghungb
Copy link

+1 for Cygwin ;)

@piyush76
Copy link

piyush76 commented May 5, 2016

it is the issue with cygwin. can't login

@roelensw
Copy link

another +1 for cygwin ( Git Bash actually )

@bigred-xx
Copy link

+1

1 similar comment
@jeremyrobertson
Copy link

+1

@dkoper
Copy link

dkoper commented Jun 21, 2016

Thanks everbody for speaking up!

I have created an exploratory story to find out what's involved (link to the story is in the next comment).

We currently do platform specific stuff to make the interactivity work, and the team's initial concern was that golang may not support what we need to implement this. This will be investigated as part of this story.

Cheers,
Dies Koper
CF CLI PM

@dkoper dkoper reopened this Jun 21, 2016
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/121914309

The labels on this github issue will be updated when the story is started.

@dkoper
Copy link

dkoper commented Jul 19, 2016

FYI, having spent a day or so investigating, the team has found no way to make this work on Windows.

It seems the required APIs are not available to us in Golang.
We'll try one more experiment (calling the Unix APIs - not sure how that will go in cygwin) just to show how desperately we'd want this to work.
If that fails, we may explore a way to at least fail with a better message instead of the loop we see now.

In the meantime, if you have any other suggestions, or can provide us with Golang sample code to make it work, we'd love to take a look!

@dkoper
Copy link

dkoper commented Jul 19, 2016

PS: the issue seems to be the same as golang/go#13088.

@ajayroy2006
Copy link

I was facing the same issue, fixed it by setting proxies , by running following command on windows
SET HTTP_PROXY=http://proxy.yourorganisation.com:port
SET HTTPS_PROXY=https://proxy.yourorganisation.com:port

@dkoper
Copy link

dkoper commented Aug 7, 2016

I have recorded this as a known issue. Closing as a won't fix while we wait for golang to support the APIs/behaviour we need.

@dkoper dkoper closed this as completed Aug 7, 2016
@dkoper dkoper added wontfix and removed unscheduled labels Aug 7, 2016
@michaellihs
Copy link

@dkoper thx for your updates!

@h0nIg
Copy link
Contributor

h0nIg commented Dec 8, 2016

it seems that golang/go#13104 was solved, will there be an update?

@h0nIg
Copy link
Contributor

h0nIg commented Dec 8, 2016

@dkoper what do you mean with "or option -f to suppress the prompts." on https://github.com/cloudfoundry/cli#known-issues

@dkoper
Copy link

dkoper commented Jan 5, 2017

@h0nIg We're still waiting for Golang to add support for this (see the golang issue I linked to, to which you also added a comment).

The option -f to suppress the prompts referred to prompts in delete commands. But I just verified they work fine, so maybe that was a mistake. I have updated the known issue entry.
PS: Comments on closed issues are hard to track with our tooling - I just found your comments by co-incidence. Better raise a new issue, re-open or ask on Slack or the CF Dev mailing list.

Cheers,
Dies Koper
CF CLI PM

@jmprice
Copy link

jmprice commented Mar 7, 2017

I haven't tested this in Cygwin specifically, but the same symptoms exists when using the cli from within a git bash shell on Windows. Adding the following alias to your .bashrc file seems to work:

alias cf='winpty cf'

or just run this from your shell: echo alias cf="'winpty cf'" >> ~/.bashrc

I hope this helps.

@blastdan
Copy link

I ran into an issue while using Babun. It doesn't seem to install winpty by default so the alias cf="'winpty cf'" >> ~/.bashrc doesn't work.

I installed https://github.com/tiangolo/babun-docker that tries to fix the same problem for docker and babun. Babun also uses zsh by default so running

echo alias cf="'winpty cf'" >> ~/.zshrc

is more appropriate

@hmaiga
Copy link

hmaiga commented May 28, 2017

+1

@saipriyabalu
Copy link

I was also facing the same issue. But I tried using in the command prompt, it works well.

@cziaul
Copy link

cziaul commented Jun 18, 2017

Also facing the same issue with git. Then as per above suggestion, I tried using cmd but getting below:

Password>
Authenticating...
Credentials were rejected, please try again.

API endpoint: https://api.local.pcfdev.io (API version: 2.75.0)
Not logged in. Use 'cf login' to log in.
FAILED
Unable to authenticate.

As you can see api.local.pcfdev.io. I have local VM, which password I should use? any default password?

@cziaul
Copy link

cziaul commented Jun 18, 2017

Just found out local default username and password

$ cf login -a https://api.local.pcfdev.io --skip-ssl-validation
Email: user
Password: pass

@aarunrohit
Copy link

Hi All,

Please follow these instructions.

Use the below command to verify your credentials.
cf login -a https://api.example.com -u username@example.com -p Password
2.
use login -a $url -u xxx@abc.com -p xxxxx instead of cf login -a $url command if you are using this in a script.

Thanks,
Arun

@jeemis23
Copy link

@Arun
use ** cf login -a $url -u xxx@abc.com -p xxxxx** instead of cf login -a $url command, works for me

@dkoper
Copy link

dkoper commented Nov 27, 2017

FWIW, cf login on my Cygwin bash seems to work fine now.

While installing the latest Git on Windows, I noticed in its release notes:

Some console programs, most notably non-MSYS2 Python, PHP, Node and OpenSSL, interact correctly with MinTTY only when called through winpty (e.g. the Python console needs to be started as winpty python instead of just python).

So @jmprice's suggestion seems to be their recommended work around.

@bakoontz
Copy link

Running under the cygwin TERM allows for interactive prompts to work. C:\cygwin64\Cygwin.bat will do this. And you still get bash.

@loganmzz
Copy link

For Windows GitBash users, it works when using bash.exe (located under bin/ subdirectory of Git installation directory). Which is useful if you're using integrated terminals from an IDE (e.g. VS Code)

@paulvi
Copy link
Contributor

paulvi commented May 10, 2019

Yes, indeed. It works if when launching Git Bash as "C:\Program Files\Git\bin\bash.exe"

image

@loganmzz if it works under some flavor of Git Bash, than it is not issue of go referenced here as golang/go#13088, but issue of configuring Git Bash or some Git Bash default settings...

@ksndrsllvn
Copy link

ksndrsllvn commented Jun 10, 2019

This was a little tricky to find. Hopefully anyone having this issue that wants to just be able to git bash finds this comment from March 2017:

I haven't tested this in Cygwin specifically, but the same symptoms exists when using the cli from within a git bash shell on Windows. Adding the following alias to your .bashrc file seems to work:

alias cf='winpty cf'

or just run this from your shell: echo alias cf="'winpty cf'" >> ~/.bashrc

I hope this helps.

(This is what I posted in my group's chat:
2) git bash will not work unless you go through some hoops (you can put your password in plain text on the same line with the -p flag (which is generally a BAD IDEA), use git cmd, run git bash from Git/bin, you can sign in under another service and go back to using git bash, OR you can actually fix the problem by setting an alias in your Git/etc/bash.bashrc with "alias cf='winpty cf'" according to a comment in the bottom of this cf issue page: )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests