It’s been almost five years and the Vagrant bug seems still there, apparently, as the semantic of vagrant ssh -c <cmd>
gets broken for every Windows box with installed OpenSSH due to the bash -l
being hard-wired.
Having no config.ssh.shell
in Vagrantfile, I’ve tried vagrant --debug ssh -c dir
, here are the logs showing bash -l
-
vagrant-ssh-bug-with-defaultshell-powershell.txt with
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
INFO ssh: Executing SSH in subprocess: C:\WINDOWS\System32\OpenSSH\/ssh.EXE ["vagrant@127.0.0.1", "-p", "2222", "-o", "LogLevel=FATAL", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "C:/Users/MateuszL/.vagrant.d/insecure_private_key", "-t", "bash -l -c 'dir'"]
-
vagrant-ssh-bug-without-defaultshell.txt without
DefaultShell
propertyINFO ssh: Executing SSH in subprocess: C:\WINDOWS\System32\OpenSSH\/ssh.EXE ["vagrant@127.0.0.1", "-p", "2222", "-o", "LogLevel=FATAL", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "C:/Users/MateuszL/.vagrant.d/insecure_private_key", "-t", "bash -l -c 'dir'"]
The only way to get the vagrant ssh
execute a (simple!) command is vagrant ssh -- dir
as per fix defaults for vagrant ssh -c on windows guests by mcandre · Pull Request #9483 · hashicorp/vagrant · GitHub which is not a solution!
Another workaround is vagrant winrm -c 'dir'
, still, not a solution, is it?