Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vagrant up : The following SSH command responded with a non-zero exit status. #1659

Closed
stattrak-dragonlore opened this issue Apr 25, 2013 · 85 comments

Comments

@stattrak-dragonlore
Copy link

Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces

$ vagrant -v
Vagrant version 1.2.2
@stattrak-dragonlore
Copy link
Author

And there is no default sync folder for path /vagrant

@stattrak-dragonlore
Copy link
Author

And vagrant halt or vagrant reload don't work:
[default] Attempting graceful shutdown of VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

shutdown -h now

@mitchellh
Copy link
Contributor

Please attach debug logs by setting VAGRANT_LOG=debug

@rfay
Copy link

rfay commented Apr 25, 2013

@dengzhp I've done this to myself any number of times by messing up the /etc/sudoers or /etc/sudoers.d. I did it today, which is why I landed here. Somewhere in /etc/sudoers (or /etc/sudoers.d if it's included) you have to have

vagrant ALL=(ALL) NOPASSWD:ALL
Defaults:vagrant !requiretty

without that, the vagrant ssh (without tty) fails mysteriously. I once again had built a machine without my puppet vagrant module, which adds this in.

@mitchellh if there's not already an FAQ on this, it's a good topic for one. I seem to do it over and over again :-)

@stattrak-dragonlore
Copy link
Author

@rfay Thanks for you reminding. Yes. The cause is that I forgot adding the user to the sudoers.

@nicolasgarnil
Copy link

Adding vagrant ALL=(ALL) NOPASSWD:ALL solved the problem as well. Thanks @rfay.

@fgrehm
Copy link
Contributor

fgrehm commented Jul 19, 2013

This seems to have been sorted out :)

@fgrehm fgrehm closed this as completed Jul 19, 2013
@therobyouknow
Copy link

@rfay :-

In your solution: #1659 (comment)

Do you change the /etc/sudoers file on the host machine or the guest VM ?

@rfay
Copy link

rfay commented Jul 30, 2013

It's the guest that's the problem here.

@therobyouknow
Copy link

OK thanks rfay (I find this happens from time to time - whether on host or guest is not specified - so thanks) but I can't get into the machine (e.g. via) ssh to change it, the failure I am having with non-zero exit status seems to have stopped the vm being created properly in order to log in to change that file.

Ideally, I'd want to know where in the Vagrant scripts I can make adjustments to add in "vagrant ALL=(ALL) NOPASSWD:ALL" so that this is part of the automation. Others here confirm this works for them but surely we want this to be part of the automation? After all this is what Vagrant is all about.

@rfay
Copy link

rfay commented Jul 30, 2013

ssh root@ip or ssh vagrant@ip. The password is 'vagrant'.

If you have the problem I had, then your problem is that you have replaced the sudoers file or otherwise damaged it. (or /etc/sudoers.d of course)

@sobi3ch
Copy link

sobi3ch commented Dec 4, 2013

Maybe this will be usefull for someone. I've fix the problem putting

%admin ALL=NOPASSWD: ALL

.. on the end(!) of the sudoers file as metiononed in this tutorial: http://brianfisher.name/content/create-vanilla-ubuntu-precise-vagrant-base-box

I don't know is it only refer to ubuntu but works for me.

@pachabhaiya
Copy link

I'm still getting the error when trying to run "vagrant up" command in Mac OS.

Error:

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -o 'vers=3,udp' 192.168.100.1:'/Users/user1/vagrant/myproject/docroot' /var/www/site/docroot
Stdout from the command:
Stderr from the command:
stdin: is not a tty
mount.nfs: mount to NFS server '192.168.100.1:/Users/user1/vagrant/myproject/docroot' failed: timed out, giving up

@rfay : I tried by adding the below entry in the sudoers file, but it still didn't help me.

vagrant ALL=(ALL) NOPASSWD:ALL
Defaults:vagrant !requiretty

Guys, please let me know if there are any other alternative solutions for this.

Thanks

@rfay
Copy link

rfay commented Jun 17, 2014

@pachabhaiya you seem to have an NFS mount problem. On your workstation host, you'll probably need to clean up /etc/exports, and in your Vagrantfile, stop mounting the docroot for now. Your problem doesn't really have to do with this issue. But I did see a damaged host /etc/exports due to a vagrant upgrade recently.

@pachabhaiya
Copy link

Thanks @rfay . Clearing /etc/exports and commenting "docroot" solves the problem.
But, when I try to mount the docroot again, it shows the same error message.
I think it's the NFS mounting issue.
Do you have any idea how this mounting issue can be fixed ?

@rfay
Copy link

rfay commented Jun 18, 2014

@pachabhaiya You'll have to debug your NFS situation, but it's not related to this issue, so let's not continue here. You will probably want to back up to using Virtualbox mounts for now, then read the various resources on the web and see how to get NFS working. Basically: See if you can manually mount your NFS mount on the guest. When you solve that problem, you'll have solved everything.

@pachabhaiya
Copy link

Thanks @rfay .

@bocharsky-bw
Copy link

@pachabhaiya Hi! Are you solved your problem with NFS? I has the same on Mac OS X

@pachabhaiya
Copy link

Yes @bocharsky-bw. It's solved in mine Mac OS X. Firewall rules were creating those problem. Turned the firewall rules off and the problem was solved. :)

@bocharsky-bw
Copy link

Oh, @pachabhaiya, thanks very much! I turned off my firewall, add slashes to sync folders and when restart my Mac - it works! :)

@lightgao
Copy link

I got similar error, but it's caused by ssh-agent.
I remove "config.ssh.forward_agent = true" in my Vagrantfile, then back to normally.

@dbanttari
Copy link

Solved (in our case) by editing /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.5/plugins/guests/debian/cap/configure_networks.rb and replacing comm.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'") with comm.sudo("cat /tmp/vagrant-network-interfaces > /etc/network/interfaces")
Using comm.sudo and 'su -c' is, afaik, redundant.

@zenmatt
Copy link

zenmatt commented Dec 1, 2014

@dbanttari Thank you, this error began randomly last week and your comment solved it.

@blink2004
Copy link

Hi, all!

Recieve after start:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

hostname -f

Stdout from the command:

Stderr from the command:

sudo: no tty present and no askpass program specified

try change hostname to 'server', didt'n work.
How can check it?

@killua99
Copy link

In my case I did "sudo service nfs-xxxx-kernel restart" and it start working. Kinda weird tho

@shivapoudel
Copy link

This issue is till not fixed:
capture-3

@adamcee
Copy link

adamcee commented Sep 21, 2016

I encountered this issue recently on OS X 10.10.5 with VirtualBox 5.0.10 and Vagrant 1.8.

Checking /etc/sudoers before and after destroying/rebuilding the machine confirmed that something similar was occuring in the sudoers file as mentioned in 17046154 - I was missing the lines:
Defaults exempt_group=sudo and the NOPASSWD:ALL part of %sudo ALL=(ALL) NOPASSWD:ALL.
Does anyone know what could be causing the sudoers file to get modified?

@arkataev
Copy link

arkataev commented Sep 23, 2016

recently I 've made a sudu apt-get dist-upgrade on my Homestead and then it started to fall down with
sudo: no tty present and no askpass program specified error.
As @rfay suggested I added ALL=(ALL) NOPASSWD:ALL Defaults:vagrant !requiretty to etc/sudoers.d/README and it worked just fine

@edosurya
Copy link

edosurya commented Sep 29, 2016

I had this same issue and updating Oracle VirtualBox and Vagrant fixed it for me.
VirtualBox 5.0.26
Vagrant 1.8.6
Windows 7

@chendo19
Copy link

chendo19 commented Oct 4, 2016

@nicolasgarnil where do I have to add this line vagrant ALL=(ALL) NOPASSWD:ALL?

@adamcee
Copy link

adamcee commented Oct 20, 2016

@rfay 's solution here seems to be working for me.

However as a relative sudoers noob I may have been adding the commands in the wrong place in /etc/sudoers. What finally worked for me was adding them, in the order listed in the comment, to a file I created in /etc/sudoers.d (/etc/sudoers was including the sudoers.d directory in my case. This include occurred at the bottom of the file).

@Changsik00
Copy link

This issue has been resolved.

I guess .. you miss "Password-less Sudo" part
https://www.vagrantup.com/docs/boxes/base.html

In another way
http://askubuntu.com/questions/406787/best-way-add-nopasswd-vagrant-user

echo vagrant ALL=NOPASSWD:ALL > /etc/sudoers.d/vagrant

@jarce6791
Copy link

I have this issue:
==> default: [DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and
==> default: make sure become_method is 'sudo' (default).
==> default: This feature will be removed in a
==> default: future release. Deprecation warnings can be disabled by setting
==> default: deprecation_warnings=False in ansible.cfg.

And after this show this issue:
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Please I need help with this

@Sufir
Copy link

Sufir commented Feb 21, 2017

I too have this problem:

==> Ubuntu Xenial 16.04 LTS x64 (PHP 7): Info: Stage[main]: Unscheduling all events on Stage[main]
==> Ubuntu Xenial 16.04 LTS x64 (PHP 7): Info: Creating state file /opt/puppetlabs/puppet/cache/state/state.yaml
==> Ubuntu Xenial 16.04 LTS x64 (PHP 7): Notice: Applied catalog in 705.36 seconds
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Config generated by puphpet, ALL=(ALL) NOPASSWD:ALL exists.

Vagrant 1.9.1
Win 8.1
VBox 5.0.32

@Nguonchhay
Copy link

I think we can resolve by this sudo killall -9 ruby as screen

If you believe this message is in error, please check the process
listing for any "ruby" or "vagrant" processes and kill them. Then
try again.

@ConAntonakos
Copy link

ConAntonakos commented Jun 27, 2017

I ran into this today. I cannot vagrant reload at all.

I'm also getting non-zero exit status error as an output, and I'm getting a Bus error.

vagrant halt/suspend, then reload helped.

@xiaoAtHouzz
Copy link

I got the same issue....Solved by restart my laptop......I dont know what to say....restarting is always a good solution...

@alpharameeztech
Copy link

I am using Ubuntu and i am getting the same error

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown 'eth1' || true
/sbin/ip addr flush dev 'eth1'
# Remove any previous network modifications from the interfaces file
sed -e '/^#VAGRANT-BEGIN/,$ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces.pre
sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tac | sed -e '/^#VAGRANT-END/,$ d' | tac > /tmp/vagrant-network-interfaces.post
cat \
  /tmp/vagrant-network-interfaces.pre \
  /tmp/vagrant-network-entry \
  /tmp/vagrant-network-interfaces.post \
  > /etc/network/interfaces
rm -f /tmp/vagrant-network-interfaces.pre
rm -f /tmp/vagrant-network-entry
rm -f /tmp/vagrant-network-interfaces.post

/sbin/ifup 'eth1'

Stdout from the command:



Stderr from the command:

bash: line 5: /sbin/ifdown: No such file or directory
bash: line 19: /sbin/ifup: No such file or directory


@briancain
Copy link
Member

Hi @alpharameeztech - That error will likely be fixed if you upgrade your version of Vagrant to the latest.

@alpharameeztech
Copy link

@briancain I am using the latest version

Vagrant 2.0.2

@briancain
Copy link
Member

@alpharameeztech - the latest version is 2.1.2. You can find that version here! https://www.vagrantup.com/downloads.html

Thanks.

@alpharameeztech
Copy link

Hey @briancain. Thank you for the update. I am gonna try and will let you know then :)

@alpharameeztech
Copy link

@briancain Gracias amigo :) the issue got resolved with a vagrant update.

@olotintemitope
Copy link

Updating from 2.0.2 to 2.2.0 solved my problem

@calinblaga
Copy link

for me it was the guest additions and:
vagrant plugin update vagrant-vbguest
did the trick

@gerrgg
Copy link

gerrgg commented Oct 2, 2019

This is how I fixed it per this comment above

Open the sudoers file (with visudo or you will break things).
$ sudo visudo

Add the following lines ABOVE the include to sudoers.d
vagrant ALL=(ALL) NOPASSWD:ALL
Defaults:vagrant !requiretty

Save, and ignore the prompt to edit the README

Reboot your system
$ reboot

@ghost
Copy link

ghost commented Jan 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests