git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.36k stars 2.54k forks source link

Username required when cloning with Plink #651

Closed stephenfin closed 8 years ago

stephenfin commented 8 years ago

tl;dr: You need to pass a username into the git clone command. I don't know if this is a documentation issue (Known issues) or a bug in the "wrapper" around plink.

I ran into a usability issue with Git for Windows when using Plink. The below command, which works perfectly in a *nix environment, fails:

git clone example.com:/home/myuser/git/myproject

The following error message is given:

fatal: protocol error: bad line length character: logi

I was able to extract the exact command being run by watching the trace (set GIT_TRACE=1), and from this I could see the exact command being run. Running this manually gives the real cause of the error:

C:\Users\myuser\Documents\>git clone example.com:/home/myuser/git/myproject
17:09:23.016776 git.c:348               trace: built-in: git 'clone' 'example.com:/home/myuser/git/myproject'
Cloning into 'myproject'...
17:09:23.078143 run-command.c:343       trace: run_command: 'C:\Program Files(x86)\PuTTY\plink.exe' 'example.com' 'git-upload-pack '\''/home/myuser/git/myproject'\'''
fatal: protocol error: bad line length character: logi
C:\Users\myuser\Documents\Development>"C:\Program Files (x86)\PuTTY\plink.exe" example.com
login as:

Appending the username resolves this problem, but it took a little to figure out. This should be fixed/documented, I think?

dscho commented 8 years ago

We only support saved connections with plink, and in those cases, it should work without user name. Are you maybe trying to use a non-saved connection with plink?

stephenfin commented 8 years ago

When you say saved, do you mean the host key has been saved? If so then yes the connection is saved per the note from "Known Issues".

dscho commented 8 years ago

Is the user name not saved as part of the connection (Putty calls this "saved session", actuall)? See http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html#plink-usage-batch

stephenfin commented 8 years ago

Doesn't look like it (ignore the ANSI escape code noise - I was using cmd.exe and MS haven't fix that yet):

C:\Users\myuser\Documents>plink.exe -ssh example.com
login as: myuser
Last login: Wed Feb 10 17:17:38 2016 from 10.252.27.91
Random MOTD stuff

←]0;~←[1;33mmyuser←[1;37m at ←[1;31mexample←[1;37m in ←[1;32m~
←[1;37m$ ←[0mexit
logout

C:\Users\sfinucan\Documents>plink.exe -ssh example.com -l myuser
Using username "myuser".
Last login: Thu Feb 11 14:28:26 2016 from 10.237.220.164
Random MOTD stuff

←]0;~←[1;33mmyuser←[1;37m at ←[1;31mexample←[1;37m in ←[1;32m~
←[1;37m$ ←[0mexit
logout

C:\Users\myuser\Documents>plink.exe -ssh example.com
login as: 
dscho commented 8 years ago

Doesn't look like it

It doesn't look like you are using saved sessions.

stephenfin commented 8 years ago

Doesn't look like it

It doesn't look like you are using saved sessions.

:disappointed: My mistake. I mistook saved sessions for saved keys, clearly. Got this working using a correct saved session

C:\Users\muser\Documents>plink.exe mysession
Using username "mysaveduser".
...

So the question becomes, is this not idiot-proof enough. It seems not, heh. What's the possibility of wrapping the plink executable such that it uses the system username if none is provided? This would be more akin to "classic Unix"-style behavior. It would be a nice little boost in the "works the way I'd expect it to" department, IMO

dscho commented 8 years ago

I would be really grateful for any Pull Request that would help making this more idiot-proof.

stephenfin commented 8 years ago

Sounds like a challenge :smile:

PhilipOakley commented 8 years ago

@stephenfin There's always the wiki and the releasenotes (etc) as easy places to 'document' the issue.. At least then google may find the answer for others in the same predicament.

Sometimes I wonder if a G4W man page might be needed as an extra to the regular man page documenation that Git provides (which can then hold all these little notelets)

swiharta commented 8 years ago

Just to chime in, I had a similar issue due to this change in behavior towards using Plink with G4W, which caught me off guard while setting up a new machine, as I hadn't saved a session and connected with Putty before installing this newer version. I also read about adding the GIT_SSH environment variable, so I did that too, but I'm not sure if that was required or if it would have been done by the installer later anyway. On uninstalling / reinstalling, I got the prompt to use Plink instead. I liked the old way better where it asked anyway without you needing to have connected. It did take me a good 30+ minutes of wasted time to learn about the issues and get it working.

I guess I can understand the argument for removing it somewhat, but another option would have been to make it a hidden / advanced option with the warning of "You probably don't want to do this" or whatever in the install wizard. The change has certainly made using Putty / Plink more cumbersome. I also have no interest in learning how to use OpenSSH. Maybe I'm uninformed about why I should be using OpenSSH, but Putty / Plink combo has been great so I don't really care as long as everything works.

dscho commented 8 years ago

It did take me a good 30+ minutes of wasted time to learn about the issues and get it working.

@swiharta I am sorry that you had to spend 30+ minutes to get it working. Please note, though, that you could at least help others avoid spending that time if you helped document this better. After all, wouldn't you have loved to find a hint in the PLink option's description about this issue? Well, here is your chance to contribute.

swiharta commented 8 years ago

I believe my documentation of the issue in a single comment is the best on the entire internet as of right now, actually. I'm not sure what you're asking me to do further. Go ahead and do it yourself I suppose.

dscho commented 8 years ago

Go ahead and do it yourself I suppose.

@swiharta please note that it is exactly this kind of behavior that forced you to spend 30+ minutes to figure things out.

Git for Windows is only as good as we make it. And that we very much includes you.

My takeaway: let's close this ticket and leave it in peace.

swiharta commented 8 years ago

You again dismiss my first comment, which summarizes the issue better than you have in all of your trolling comments to other users. I spent time putting all of the information in there and you don't appreciate it but blast me for, I assume, not submitting a pull request? I don't even know how to use git, let alone code anything, sir. You are doing nothing to help the situation, instead spending much energy demonizing me as some irresponsible user, when in reality, I could have saved my time by not commenting and summarizing all of the issues in the first place. I've seen you do this in other threads. This is why this issue persists. Because you ignore it, berate users for ineptitude, and close their issues. Goodbye.