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

Automaticlly prompt password input when it need #310

Open
eromoe opened this issue Jan 4, 2017 · 3 comments
Open

Automaticlly prompt password input when it need #310

eromoe opened this issue Jan 4, 2017 · 3 comments
Labels
enhancement New feature or improvement

Comments

@eromoe
Copy link

eromoe commented Jan 4, 2017

Sometims I just type

$ git ftp push
fatal: Could not get last commit. Network down? Wrong URL? Use 'git ftp init' for the initial push., exiting...

But not work, then I found that this sftp need password (some sensitive vps).That tip message doesn't looks like saying I missing the password, just not so friendly.

Then I remmenber to type git ftp push -P (easy forgot)

I think it would be much better to prompt password input when authentication failed.

@mkllnk mkllnk added the enhancement New feature or improvement label Jan 4, 2017
@LukasFritzeDev
Copy link
Collaborator

We are already discussing a better check for this kind of connection errors in #285. But there is no easy option to distinguish between an invalid password or an invalid username – in both cases curl returns curl: (67) Access denied: 530. So we can’t say which one was wrong.

But what we could do is checking if any auth information is given (password, ssh key, keychain). If not we could prompt password input before we even send a request. This should also work with .netrc since this is only applied if username is not set.

So we would have 3 cases:

  1. user && auth set : do everything as usual
  2. ! user && ! auth se t: try .netrc
  3. user && ! auth : prom for password automatically

@mkllnk
Copy link
Member

mkllnk commented May 24, 2019

@dertanzschuh I think it's quite difficult to detect every possible authentication. For example, curl can auto-detect the location of the SSH key. We would need to re-implement that detection to see if there is a key and it may not be the right one.

If we can easily see that it's a curl error 67, we could at least say: "Access denied. Did you mistype the URL, username or password?"

@LukasFritzeDev
Copy link
Collaborator

For example, curl can auto-detect the location of the SSH key.

As far as I know curl can only detect the public key, but the private key must be set with --key. There is not hint to this in the manual other than those:

you can use the --key option to specify a private key

Get a file from an SSH server using SCP using a private key (not password-protected) to authenticate:
curl -u username: --key ~/.ssh/id_rsa scp://example.com/~/file.txt

So we could assume key auth is used if a private key is set, regardless of a public key, couldn’t we?


If we can easily see that it's a curl error 67, we could at least say: "Access denied. Did you mistype the URL, username or password?"

Yes, we can. But I think this is the fix for the other issue I mentioned. 😉
To check this we have to send a request to the server. And I think it’s better to quit in such a case, because maybe the authentication failed because of a username mistype in a config file and this is hard to fix on the fly.
I would try to catch the missing auth and warn the user before any request is sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants