windows os: vagrant ssh dont' work with git - windows

I'm trying to use vagrant ssh in windows console, but it don't work.
Vagrant is correctly installed, and i've installed also Git for windows.
Also, correct path is installed in the system environment, using
setx PATH "%PATH%;C:\Program Files (x86)\Git\bin"
and i can see the path add-on in the console via path and also in the windows system environment.
But when i'm use vagrant ssh in the windows console it give me the usual error:
ssh executable not found in any directories in the %PATH% variable.
Is an SSH client installed? Try installing Cygwin, MinGW or Git, all
of which contain an SSH client. Or use your favorite SSH client with
the following authentication information shown below:
Host: 127.0.0.1 Port: 2222 Username: vagrant Private key:
C:/vagtest/.vagrant/machines/default/virtualbox/private_key
If i digit path in console, i have the correct path with git location, but it is useless.
If i digit
set PATH=%PATH%;C:\C:\Program Files (x86)\Git\bin
the command
vagrant ssh run, but obviusly when i close the console and reopen it, it don't run more.
I really don't understand what happen.

try >vagrant ssh from Git Bash window

To run ssh on windows, you need to download msysgit from msysgit project page and copy the ssh.exe file from msysgit/bin folder to C:\Program Files\Git\bin.
Now try again vagrant ssh from cmd, git cmd or git bash.
Note: if you prefer, you can include the msysgit/bin to path, or copy all the content of msysgit/bin to git/bin.

Related

env PATH not working when I openssh to Windows server

I've set up git on a windows machine with a working PATH environment variable. From both the command line and Cygwin terminal I can use
git status
I've also installed ssh as a service using Cygwin and sshd using the guide here: https://docs.oracle.com/cd/E23562_01/doc.1035/e14501/install.htm. I can successfully ssh to the machine using Putty, but when I try to run git commands, it seems the PATH I've set up doesn't work. Instead I get:
-bash: git: command not found
Is there any way to get this working with a PATH variable? This is going to be used by Jenkins so I have limited control over how the git commands are called.
I guess Cygwin or the ssh client maintains its own PATH so I just needed to add my git.exe path in my ssh session in this way:
export "PATH=$PATH:/cygdrive/c/Program Files/Git/cmd"

vagrant ssh not working in MobaXterm on Windows

I have already found "SSH to Vagrant box in Windows" and added the git bin directory to my windows PATH. I verified that it worked by starting CMD and typing ssh, and got a usage message. (Before adding the git bin directory to my path, CMD complained that ssh wasn't a valid command.)
However...when I run vagrant ssh from MobaXterm, I get the same error I did before. (A page full of ruby errors that aren't helpful to me.) When I run it as VAGRANT_LOG=debug vagrant ssh, I see:
INFO subprocess: Starting process: ["C:\\Users\\(myname)\\DOCUME~1\\MOBAXT~1\\slash\\bin/ssh.EXE"]
This is the wrong ssh executable; it's the one installed in MobaXterm and it doesn't work if run from a CMD window.
How can I get vagrant ssh to work as it should?
Part of the trick is that I don't want to use the Windows PATH for arbitrary commands—not even for ssh, really. I want to use the versions in MobaXterm for everything. All I want is to be able to run vagrant ssh the same way I would on Linux or Mac.
The workaround I have been using, which I found somewhere online (but can't find the page again), is:
vagrant ssh-config > vagrant-ssh
ssh -F vagrant-ssh default # Works exactly the way `vagrant ssh` should
"default" is the box name for a typical Vagrant environment with only a single vagrant box. If there is more than one box, replace "default" with the box name:
ssh -F vagrant-ssh host001 # Works the way `vagrant ssh host001` would on another system
This is a good workaround with minimal changes required to workflow. But I'd still like a way to get vagrant ssh working without needing the extra file in my vagrant directory.
here you can find an explanation
In the documentation, this mention is in the "Terminal tab settings"
section, so you will find this option in the "Terminal" tab.
Go to MobaXterm global settings window, then click on the "Terminal"
tab and check the "Use Windows PATH environment". Note that if you are
using a session, you will have to do the same in this session: edit
your session, then go to the "Terminal settings" tab and check the
"Use Windows PATH" option.
Call me crazy but what about doing this:
Setup Vagrant Virtualbox VM like normal
In MobaXterm, create a "Bash" shell integration with the working directory setup as the directory of the Vagrant directory for the specific VM you are doing this for (aka ... the directory where the Vagrantfile lives for this VM)
In the "Advance Shell Settings", use this command (adjust vagrant path to where ever your Vagrant is installed as MobaXterm bash sees it):
command /drives/c/HashiCorp/Vagrant/bin/vagrant ssh-config >
vagrant-ssh-config && ssh -A -F vagrant-ssh-config default
Vagrant VM needs to be up for MobaXterm Bash entry for the VM to work. I just setup two Bash shell settings for two Vagrant Virtualbox VMs I created and it seems to work just fine.
Updated: I went a little further since I've figured this out .. at least for me I did :). I added additional CMD shell sessions MobaXterm for each of my Vagrant VM. These additional CMD shell sessions do Vagrant halt, up, and restart (combo of halt and up) commands against the VMs they are specific to. This is what restart looks like:
vagrant halt
vagrant up
set /p value="Press Enter to continue"
exit
The Startup Directory for the above session is, again, the directory where the Vagrantfile lives for this VM. Oh, and make sure that "Use Windows PATH" is checked in Terminal Settings.
you can install git (https://git-scm.com/downloads) during install git choose "use git and optional Unix tools from the windows command prompt"
Download msysgit from msysgit project page and include msysgit/bin folder to PATH, now you can run ssh and vagrant ssh form your terminal on windows.

"Failed to add the host to the list of known hosts" Windows prompt

I wanted to try and use git in my regular Windows prompt instead of in Git Bash. Simply for the reason that I could then use the terminal that IntelliJ provides. I figured it to be a 1 minute fix but I guess not.
When I try to git pull origin <branch> I get the following error message:
C:\Users\Username\Documents\Bitbucket\java-project>git pull
Could not create directory '/c/Username/.ssh'.
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 12:8c:1b:f2:6d:14:6b:5c:3b:ec:aa:46:46:xy:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/c/Username/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have set the permissions on the existing .ssh folder such that all Users have full access, administrators and SYSTEM. So that should be okay.
I also tried to run the prompt as Administrator to see if that was the issue but that's not the case either.
What I do notice now is that it says: Could not create directory '/c/Username/.ssh'.. However, my .ssh directory is located at C:\Users\Username\.ssh. I might need to change my configuration then.
Git version: 1.9.0.msysgit.0
Windows version: Windows 8.1
First of all, tested with msysgit 1.9.2, when one selects to make just git command available from cmd.exe during installation (where other choices are, make it avaiable only under git bash, or make all MSYS commands available under cmd.exe), git clone works from cmd.exe prompt.
The ssh client uses HOME environment variable to find .ssh/ directory, but git should take care of all the ugly details. You should not have HOME defined in your normal Windows environment, so if echo %HOME% in cmd.exe prompt prints a path, edit the OS environment variables and remove HOME.
If that does not solve it, uninstalling and installing latest version might help.
Finally, you have paths like C:UsersUsername, it probably means you're missing quotes somewhere. In git bash, try these two commands to see:
echo C:\Users\Username
echo 'C:\Users\Username'
Make sure you type your cmd session the git-cmd.bat which comes with every Git For Windows msysgit release.
That will set your HOME to %USERPROFILE%, which should be C:\Users\Username.
But make sure you didn't have an environment variable HOME already defined with an incorrect value: unset it if that is the case.
Open Git Bash console.
Perform the command below to enable read and write;
chmod 776 your local path here/known_hosts
More details here

Why doesn't git clone work with bitvise tunnelier on windows?

I am trying to clone a repo to my laptop from my main PC. Both systems use windows 7 (I know, go to linux). They also both have the latest msysgit running.
On the PC I have bitvise server for SSH, and have the client version running on the laptop. Git is setup as an env path in windows, and I can log into the PC from the laptop via SSH (keys have been shared, homepath set etc.)
When I type the following into msysgit on the laptop, I get an error:
git clone username#192.168.1.5:XABC
fatal: ''XABC'' does not appear to be a git repository
now if I type ssh username#192.168.1.5 ls XABC/.git I get the expected
COMMIT_EDITMSG
FETCH_HEAD
HEAD
etc.
What am I doing wrong?
Try cloning the remote repository with this command:
git.exe clone -v "ssh://user#XXX.XXX.XX.XX:YY/path/to/git/repo/repo.git" "C:\path\to\desired\clone"
Where XXX.XXX.XX.XX is the remote IP address and YY is the port, usually 22 for ssh service.
Haven't tried it but it should work.
Also, check this answer and this blog post.
Hope it helps!
I used this combination long time ago.
Try using absolute dir and MSDOS(yes! C:\\FOO\\BAR) dir syntax with BitVise sshd, which does not include a unix-style dir hosting, unlike Cygwin.
I suspect this is a dir presenting issue. So I suggest using pscp.exe from putty, do a successful scp on your .git file and use the url you had luck on.
Anyway git don't care about storage and network, you can clone via windows share, ftp, another dir, and even Dropbox dir...

Git fatal: remote end hung up

So I thought I had finally got everything setup on Windows ... then ran into this issue.
Current setup
URL: ssh://user#host:port/myapp.git
Already run Putty - and can connect using valid .ppk keys through the ~/.ssh/authorized_keys direct. In Git and TortoiseGIT - I set both to use "plink.exe".
Putty works fine - no issues - but when I run that URL into bash I get for a git clone (url)
fatal: the remote end hung up expectedly
In a cygwin bash terminal - running "ssh user#host" - works no probs at all.
Anyone suggest anything?
I found out that using ssh.exe from the Git package works every time, as opposed to the ssh that comes with cygwin (the default).
Using this exported variable seems to help; it's slower (2x or more) but it's more stable. Take it as another workaround.
$ export GIT_SSH=/cygdrive/c/Program\ Files/Git/bin/ssh.exe
FYI:
This version of Msysgit comes with OpenSSH 4.6p1, OpenSSL 0.9.8e. [works]
Cygwin's SSH is OpenSSH 5.5p1, OpenSSL 0.9.8n. [doesn't work]
I had the same problem with plink for git under windows.
On run of plink.exe -v xxx#host.com it started to show
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
login as: <<< trouble
Instead of
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
Using user "xxx"
To resolve this problem I cleaned up the putty registry records and sessions by
putty.exe -cleanup
After that plink starts afresh and asks to trust and store the host again and it is getting connected with no problem !
Try following steps, maybe something will give you a hint on your problem:
1. Run putty and after setting up server name/user name/keys etc. save those settings.
2. Run plink.exe or plinkw.exe like plink.exe user_name#server, (it'll throw some info at you) just to see if plink can connect to the server.
3. Check again that git knows that it should use plink, I'd say with all VCSs, that's the problem people have most often, apart from their keys not being set up properly.
Normally by now most of your ssh problems would be revealed. Now just fix them. :)
Update:
I think the problem you have is caused by several gits you've got installed. For the msysgit and cygwin git you'd need to set the GIT_SSH variable. That's done via either 'set GIT_SSH=c:\path\putty\plink.exe' or 'export GIT_SSH=/your/path/putty/putty.exe' respectively. If you're also using tortoise git, you'd need to locate 'properties' (or is it settings?) in it's menu, and set the ssh client there.
Apart from all that, when specifying git clone URL, use your login name and the server name in there, e.g. 'git clone ssh://user#server/your/path/repo.git User and server names should be used by plink, and plink should be able to connect to the server with those arguments, when all of those requirements are met, you'll be all set.
Good luck.
If you want to try the cygwin openssh 5.4p1-1, which does seem to work for this, unlike 5.5 or 5.6, you can use the cygwin time machine mirrors. Start setup.exe with -X and add a mirror Url, such as:
ftp://www.fruitbat.org/pub/cygwin/circa/2010/05/20/230133
Be careful not to install too much, i.e. base packages, from an older mirror than the rest of your install.
We had same problem and here is solution how we solved the problem:
at first we got:
zajdan#cyberFuture:~$ git clone ssh://nette#19X.16X.14X.7X/~repos/erotika.git/ erotika
Initialized empty Git repository in /home/zajdan/erotika/.git/
Password:
fatal: '/repos/erotika.git': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly
zajdan#cyberFuture:~$
solution:
zajdan#cyberFuture:~$ git clone ssh://nette#19X.16X.14X.7X/~/repos/erotika.git/ erotika
after tilde there must be a slash!
I have exactly the same issue.
I don't use Putty (just Cygwin).
I use Windows 7 Ultimate (fully patched as of this moment).
I just installed Cygwin yesterday.
I made sure binary mounts were being used.
If I copy a git repo to the machine (via samba mount), I can clone it, but when I "git diff" after the clone, there are a bunch of "different" files with no diffs. After a "git status" there was no output from "git diff". It seems like a newline thing, but I can't figure out how that would be happening. (I have igncr in SHELLOPTS, but removing that doesn't fix it.)
I'm completely stumped.
Check the openssh version you're using in CygWin. Version 5.5p1-1 (which is the latest at this time) gave me the same error. Downgrading to 5.4p1-1 fixed the problem.
Another solution would be to use putty/plink instead of openssh.
For more details, see this thread: http://www.mail-archive.com/cygwin#cygwin.com/msg103752.html
I get message: "remote end gung-up, unexpected EOFs, index-pack failed" while cloning git repo but was able to workaround this issue with copssh http://sourceforge.net/projects/sereds/files/Copssh
The root cause is Cygwin openssh package.
I removed original openssh from Cygwin, installed copssh and set GIT_SSH variable to point copssh binaries. After this I simply added copssh binaries in the PATH and now I'm using copssh instead of openssh - there is no difference.
Everything works fine and issue does not appear any more.
The other solution is to use mSysGit package.
I believe the real problem is that cygwin's ssh looks for .ssh in /home/name/.ssh and mingw's git ssh looks for .ssh in c:/user/name/.ssh
Chances are your keys are in one and only one of these directories.
You can trying telling cygwin's .ssh to use a different identity file using the -i switch, or move the keys into both directories, or create an ssh config file in /home/name/.ssh/config.
I created a config that contains:
Host github.com
User jerryasher
Hostname github.com
IdentityFile c:/Users/jerry/.ssh/id_rsa
And given that I can use either the mingw git from git bash or cygwin's git from an rxvt to interact with github.
To correct this issue, run "plink -agent github.com"
Press y when prompted to cache the key. Login as git. You'll automatically be disconnected. And it sould work.
Source: http://devlicio.us/blogs/sergio_pereira/archive/2009/05/06/git-ssh-putty-github-unfuddle-the-kitchen-sink.aspx
Try to use absolute path to repo in a URL, that worked for me.
Instead of:
git ssh://user#host:port/myapp.git
Write:
git ssh://user#host:port//home/user/repo/myapp.git
Notice the double slash!

Resources