6

If I vagrant ssh with windows cmd, I get a nice command prompt, like that:

vagrant@homestead:~$ echo foo
vagrant@homestead:~$ foo

But with cygwin and mintty, I have no prompt at all:

echo foo
foo

I see it has to do with "pseudo-tty allocation".

With cygwin and mintty, I can have my prompt with this :

vagrant ssh -- -t -t

How can I change cygwin and mintty so that I don't have to tell the -t ?

About the ssh -t option :

"Force pseudo-tty allocation. This can be used to execute arbi- trary screen-based programs on a remote machine, which can be very useful, e.g., when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty."

5 Answers 5

6

I had the same problem with and the solution was to set the VAGRANT_PREFER_SYSTEM_BIN environment variable to get vagrant to use your normal ssh executable.

You can do:

VAGRANT_PREFER_SYSTEM_BIN=1 vagrant ssh

or put this into your .bash_profile:

export VAGRANT_PREFER_SYSTEM_BIN=1

Reference: https://github.com/hashicorp/vagrant/issues/9143#issuecomment-343311263

2

I run in the same problem described above. But only on one of three PCs. But as a workaround I am doing:

# save the config to a file
vagrant ssh-config > vagrant-ssh

# run ssh with the file.
ssh -F vagrant-ssh default

From an answer of How to ssh to vagrant without actually running "vagrant ssh"?

In this case I am getting the prompt and what's more important also history cycling and ctrl-c etc. are working properly.

1
  • After upgrading to Vagrant 1.9.7, "vagrant ssh" is working as expected (prompt is showing and all the other stuff).
    – Uriziel47
    Commented Jul 10, 2017 at 8:00
1

Vagrant is a windows program managing Virtual machine
https://www.vagrantup.com/intro/index.html

as such it does not well interface with the pseudo tty structure used by cygwin programs. Read for reference on similar issues with a lot of other windows program
https://github.com/mintty/mintty/issues/56

Mintty is a Cygwin program. It expect interactive program running inside it to use the cygwin tty functionality for interactive behaviour. Running Vagrant from Bash in Windows CMD, make CMD the terminal control so Vagrant has no problem in the interactive behaviour.

I do not see the need to run Vagrant inside Cygwin

2
  • 1
    But it really has to do with mintty. If I'm in cmd and run this : C:\cygwin64\bin\bash --login -i , I can then do vagrant ssh and getting a command prompt.
    – trogne
    Commented Jul 6, 2017 at 18:29
  • 1
    But if I use mintty.exe, vagrant ssh results in an empty command prompt. I'm connected, but without the leading "vagrant@homestead:~$"
    – trogne
    Commented Jul 6, 2017 at 18:35
0

Since vagrant is windows-based, I use ConEmu instead of cygwin's shell (mintty)

choco install conemu via chocolatey and it works

0

General solution is to teach vagrant to use ssh, compatible with preferred terminal. Like Cygwin ssh+mintty.

Modern Vagrant (v2.1.2) has VAGRANT_PREFER_SYSTEM_BIN=1 by default on Windows.

To troubleshoot issue:

VAGRANT_LOG=info vagrant ssh

In v2.1.2 they broke Cygwin support. See my bug report with hack to lib/vagrant/util/ssh.rb to make it work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.