cloudfoundry / cli

The official command line client for Cloud Foundry

Home Page:https://docs.cloudfoundry.org/cf-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"cf login " interactive password prompt fails on cygwin

gberche-orange opened this issue · comments

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

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.

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
[...]

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.

@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)

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.

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

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

+1

-1 for cygwin or windows...

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

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.

+1

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

commented

+1 for Cygwin ;)

it is the issue with cygwin. can't login

commented

another +1 for cygwin ( Git Bash actually )

+1

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

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.

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!

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

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

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 thx for your updates!

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

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

@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

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.

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

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

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?

Just found out local default username and password

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

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

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

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.

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

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)

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...

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: )