Open guillermo-jano opened 2 years ago
Which version of Git for Windows are you running?
I have currently pinned my version to 2.34.1 because of this issue. I only had issues with the keyboard interrupt with versions after that.
@guillermo-jano See https://github.com/git-for-windows/git/issues/3716 and https://github.com/git-for-windows/git/issues/3848.
As I mentioned in the issue description for me this only happens when the ssh
command is launched by Vagrant. If I run vagrant --debug ssh
I can see:
INFO ssh: Invoking SSH: C:\Program Files\Git\usr\bin/ssh.EXE ["vagrant@127.0.0.1", "-p", "2200", "-o", "LogLevel=FATAL", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "C:/Projects/SD/sources/vagrant-test-ctrl-c/.vagrant/machines/default/virtualbox/private_key"]
If I Ctrl-C from that session, I observe the problem. However if I run the exact same command directly:
$ 'C:\Program Files\Git\usr\bin/ssh.EXE' "vagrant@127.0.0.1" -p 2200 -o LogLevel=FATAL -o Compression=yes -o DSAAuthentication=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i C:/Projects/SD/sources/vagrant-test-ctrl-c/.vagrant/machines/default/virtualbox/private_key
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)
[...]
Ctrl-C works without a problem in that session.
I am also seeing this same issue (session exits upon pressing ctrl+c) with cygwin shell and cygwin openssh / ssh client. However when using vagrant supplied ssh client via windows cmd.exe shell ( not using cygwin ) then the ctrl+c does not kill the ssh client session. Additionally, as others reported, if I launch cygwin ssh directly (not via vagrant) then the ssh client behaves as expected and does not exit session when pressing ctrl+c. So it appears that the problem is related to the way vagrant is launching the ssh task.
Same issue happens on Vagrant 2.2.19 with Cygwin terminal.
Same thing happened for me. I was able to aleviate the issue by switching from Git's ssh.exe to the Windows 10 ssh.exe.
Git for Windows comes with its own bundled ssh.exe. Windows 10 comes with OpenSSH installed which also has ssh.exe. The location is listed in the environment variables. I think vagrant is designed to work with this Windows 10 ssh.exe, not the Git for Windows (v2.38.0) ssh.exe.
Edit: as @demotodo mentioned, vagrant comes with its own ssh.exe so this may also be what's being used.
When installing Git for Windows, I selected the "Use external OpenSSH" option and now vagrant ssh
and Ctrl + c is working fine.
I experience this even with powershell and windows 10 native ssh.
PS devenv> Get-Command ssh
CommandType Name Version Source
----------- ---- ------- ------
Application ssh.exe 8.1.0.1 C:\Windows\System32\OpenSSH\ssh.exe
PS devenv> vagrant ssh
Last login: Tue Oct 18 15:06:38 2022
[vagrant@jacob ~]$
^C
[vagrant@jacob ~]$ PS devenv>
PS devenv>
A temporary workaround (for Win10/cygwin) is to run own ssh client with custom vagrant config (host/port/key): https://stackoverflow.com/questions/10864372/how-to-ssh-to-vagrant-without-actually-running-vagrant-ssh
Another workaround which is also much more faster than vagrant ssh
:
alias fastssh="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i .vagrant/machines/default/virtualbox/private_key -p 2222 vagrant@127.0.0.1"
This
solution I found was quite nice:
#!/bin/sh
PORT=$(vagrant ssh-config | grep Port | grep -o '[0-9]\+')
ssh -q \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-i ~/.vagrant.d/insecure_private_key \
vagrant@localhost \
-p $PORT \
"$@"
Put the above in a file \~/scripts/vagrant-ssh.sh Then add an alias to the script: alias vagrant-ssh='\~/scripts/vagrant-ssh.sh' or add the script to the execution path.
Which version of Git for Windows are you running?
I have currently pinned my version to 2.34.1 because of this issue. I only had issues with the keyboard interrupt with versions after that.
helped me, thanks a lot
I fixed this issue on my PC installing the Windows optional feature "OpenSSH client" and adding to the System Path the line "C:\Windows \system32\OpenSSH" on top. In this way, vagrant ssh works flawlessly.
I am having this issue with Windows Terminal as well: Version: 1.20.11381.0. Doesn't matter what shell I use, I've tried Powershell 7, Powershell 5, cmd.exe. Vagrant 2.4.1.
Vagrant version
2.3.0
Host operating system
Windows 10 21H2
Guest operating system
Linux
Vagrantfile
Debug output
N/A
Expected behavior
One should be able to use Ctrl+C within a
vagrant ssh
session. This is not the case with Git Bash or MSYS2 (both based on Mintty), works fine from Windows Terminal or the classic console window host.Actual behavior
When you hit Ctrl+C you are taken back to the original shell from which
vagrant ssh
was run. Also, thessh.exe
process is not stopped, it just stays on the background. So it is like it is eithervagrant.exe
orruby.exe
which is receiving the signal instead ofssh.exe
.I have tried obtaining the SSH configuration using
vagrant ssh-config
and launching the same SSH executable Vagrant is using by hand and Ctrl+C works as expected within that session. So this looks related to the wayvagrant.exe
is runningssh.exe
.Finally I have to say this wasn't always like this, I have noticed this change in behaviour just some months ago. Unfortunately at first I thought this was an issue with Visual Studio Code, because I run
vagrant ssh
from a VS Code terminal most of the time, but recently I tried to do the same directly from an MSYS2 terminal window (and also Git Bash just to check) and found the same behaviour. Like I said, this was not the case not so long ago.Steps to reproduce
vagrant ssh
from a Git Bash or MSYS2 terminal windowReferences
N/A