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
dengzhp opened this Issue Apr 25, 2013 · 82 comments

Comments

Projects
None yet
@dengzhp

dengzhp commented Apr 25, 2013

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
@dengzhp

This comment has been minimized.

dengzhp commented Apr 25, 2013

And there is no default sync folder for path /vagrant

@dengzhp

This comment has been minimized.

dengzhp commented Apr 25, 2013

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

This comment has been minimized.

Member

mitchellh commented Apr 25, 2013

Please attach debug logs by setting VAGRANT_LOG=debug

@rfay

This comment has been minimized.

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 :-)

@dengzhp

This comment has been minimized.

dengzhp commented Apr 26, 2013

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

@nicolasgarnil

This comment has been minimized.

nicolasgarnil commented Apr 30, 2013

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

@fgrehm

This comment has been minimized.

Collaborator

fgrehm commented Jul 19, 2013

This seems to have been sorted out :)

@fgrehm fgrehm closed this Jul 19, 2013

@therobyouknow

This comment has been minimized.

therobyouknow commented Jul 30, 2013

@rfay :-

In your solution: #1659 (comment)

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

@rfay

This comment has been minimized.

rfay commented Jul 30, 2013

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

@therobyouknow

This comment has been minimized.

therobyouknow commented Jul 30, 2013

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

pachabhaiya commented Jun 17, 2014

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

This comment has been minimized.

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

This comment has been minimized.

pachabhaiya commented Jun 18, 2014

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

This comment has been minimized.

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

This comment has been minimized.

pachabhaiya commented Jun 18, 2014

Thanks @rfay .

@bocharsky-bw

This comment has been minimized.

bocharsky-bw commented Jun 23, 2014

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

@pachabhaiya

This comment has been minimized.

pachabhaiya commented Jun 23, 2014

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

This comment has been minimized.

bocharsky-bw commented Jun 23, 2014

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

@lightgao

This comment has been minimized.

lightgao commented Nov 28, 2014

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

This comment has been minimized.

dbanttari commented Dec 1, 2014

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

This comment has been minimized.

zenmatt commented Dec 1, 2014

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

@blink2004

This comment has been minimized.

blink2004 commented Dec 26, 2014

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

This comment has been minimized.

killua99 commented Mar 14, 2015

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

@shivapoudel

This comment has been minimized.

shivapoudel commented Apr 14, 2015

This issue is till not fixed:
capture-3

@ConnectedCat

This comment has been minimized.

ConnectedCat commented Aug 5, 2016

have the same issue here as @razbakov

@razbakov

This comment has been minimized.

razbakov commented Aug 6, 2016

I posted more detailed report in #7646

@aidygus

This comment has been minimized.

aidygus commented Aug 11, 2016

Same problem as @razbakov

Windows 7, Vagrant 1.8.5, VB 5.1.2

@festum

This comment has been minimized.

festum commented Aug 28, 2016

Same as @razbakov
Windows 10 1511 x64, Vagrant 1.8.5, VBox 5.1.2

@oscarAG

This comment has been minimized.

oscarAG commented Sep 12, 2016

Hey everyone, I had this same issue and updating Oracle VirtualBox fixed it for me.

@ito2307

This comment has been minimized.

ito2307 commented Sep 14, 2016

I was using my Vagrant/homestead on Windows, i was programming in my project just when I want to close my homestead, not I allowed to close it simply, because showed me this message, also remember having running sudp apt-get upgrade, to install the latest version of the ldap.

zendframework/zend-ldap 2.7.1 requires ext-ldap * -> the requested PHP extension ldap is missing from your system.

sudo apt-get install php7.0-ldap [default] GuestAdditions versions on your host (5.1.6) and guest (5.1.4) do not match. sudo: no tty present and no askpass program specified sudo: no tty present and no askpass program specified ==> default: Checking for guest additions in VM...

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

apt-get update

Stdout from the command:

Stderr from the command:

sudo: no tty present and no askpass program specified
, had that force it with vagrant halt - force, is it?

i changed with
#sudo su
#vim /etc/sudoers

This file MUST be edited with the 'visudo' command as root.

Please consider adding local content in /etc/sudoers.d/ instead of

directly modifying this file.

See the man page for details on how to write a sudoers file.

Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

Host alias specification

User alias specification

Cmnd alias specification

User privilege specification

root ALL=(ALL:ALL) ALL

Members of the admin group may gain root privileges

%admin ALL=(ALL) NOPASSWD:ALL

Allow members of group sudo to execute any command

%sudo ALL=(ALL:ALL) ALL

See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

but i still have the same problem

@adamcee

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

chendo19 commented Oct 4, 2016

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

@adamcee

This comment has been minimized.

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

This comment has been minimized.

Changsik00 commented Nov 17, 2016

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

jhajek added a commit to jhajek/packer-vagrant-build-scripts that referenced this issue Dec 23, 2016

@jarce6791

This comment has been minimized.

jarce6791 commented Feb 9, 2017

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

This comment has been minimized.

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

This comment has been minimized.

Nguonchhay commented Mar 20, 2017

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

This comment has been minimized.

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

This comment has been minimized.

xiaoAtHouzz commented Mar 26, 2018

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

@alpharameeztech

This comment has been minimized.

alpharameeztech commented Aug 1, 2018

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

This comment has been minimized.

Member

briancain commented Aug 1, 2018

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

@alpharameeztech

This comment has been minimized.

alpharameeztech commented Aug 1, 2018

@briancain I am using the latest version

Vagrant 2.0.2

@briancain

This comment has been minimized.

Member

briancain commented Aug 1, 2018

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

Thanks.

@alpharameeztech

This comment has been minimized.

alpharameeztech commented Aug 2, 2018

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

@alpharameeztech

This comment has been minimized.

alpharameeztech commented Aug 3, 2018

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

@andela-tolotin

This comment has been minimized.

andela-tolotin commented Oct 26, 2018

Updating from 2.0.2 to 2.2.0 solved my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment