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

Created on 25 Apr 2013  ·  85Comments  ·  Source: hashicorp/vagrant

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

Most helpful comment

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

All 85 comments

And there is no default sync folder for path /vagrant

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

Please attach debug logs by setting VAGRANT_LOG=debug

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

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

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

This seems to have been sorted out :)

@rfay :-

In your solution: https://github.com/mitchellh/vagrant/issues/1659#issuecomment-17046154

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

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

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.

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)

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.

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

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

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 ?

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

Thanks @rfay .

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

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

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

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.

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.

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

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?

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

This issue is till not fixed:
capture-3

@shivapoudel +1

anyone has a solution for windows?

Same problem here! Not sure what it is!

same problem..

Guys I have the following issue:

0
down vote
favorite
I am starting using Rancher and Vagrant to create my local environment for development. Steps that I've done:

1) I already had VirtualBox installed.
2) I download and installed the Vagrant package for linux with

sudo rpm -i vagrant_1.7.2_x86_64.rpm
After typing:

vagran --version
I got

Vagrant 1.7.2
3)Then I cloned the Rancher repo from GitHub:

git clone [email protected]:rancherio/rancher.git
Which has the Vagrant file.

4)After executing:

sudo vagrant up
Which is the step where I get the error, I got this:

==> rancher: Box 'coreos-alpha' could not be found. Attempting to find and install...
rancher: Box Provider: virtualbox
rancher: Box Version: >= 308.0.1
==> rancher: Loading metadata for box 'http://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json'
rancher: URL: http://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json
==> rancher: Adding box 'coreos-alpha' (v709.0.0) for provider: virtualbox
rancher: Downloading: http://alpha.release.core-os.net/amd64-usr/709.0.0/coreos_production_vagrant.box
rancher: Calculating and comparing box checksum...
==> rancher: Successfully added box 'coreos-alpha' (v709.0.0) for 'virtualbox'!
==> rancher: Importing base box 'coreos-alpha'...
==> rancher: Matching MAC address for NAT networking...
==> rancher: Checking if box 'coreos-alpha' is up to date...
==> rancher: Setting the name of the VM:rancher_rancher_1434213461241_51852
==> rancher: Clearing any previously set network interfaces...
==> rancher: Preparing network interfaces based on configuration...
rancher: Adapter 1: nat
rancher: Adapter 2: hostonly
==> rancher: Forwarding ports...
rancher: 8080 => 8080 (adapter 1)
rancher: 22 => 2222 (adapter 1)
==> rancher: Running 'pre-boot' VM customizations...
==> rancher: Booting VM...
==> rancher: Waiting for machine to boot. This may take a few minutes...
rancher: SSH address: 127.0.0.1:2222
rancher: SSH username: core
rancher: SSH auth method: private key
rancher: Warning: Connection timeout. Retrying...
rancher:
rancher: Vagrant insecure key detected. Vagrant will automatically replace
rancher: this with a newly generated keypair for better security.
rancher:
rancher: Inserting generated public key within guest...
rancher: Removing insecure key from the guest if its present...
rancher: Key inserted! Disconnecting and reconnecting using new SSH key...
==> rancher: Machine booted and ready!
==> rancher: Setting hostname...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

systemctl start [email protected]

Stdout from the command:

Stderr from the command:

Job for [email protected] failed because a configured resource limit was exceeded. See "systemctl status [email protected]" and "journalctl -xe" for details.
Then when i go to the localhost:8080 there is no Rancher UI installed.

I'd really appreciate any help whit this.

eduartua I'm also having same error in another instance with CoreOS.

When I did vagrant up Then got following error:-
DEBUG ssh: Exit status: 6
ERROR warden: Error occurred: The SSH command responded with a non-zero exit status. Vagrant

Please any one can help to fix this problem

@rfay :- can you pls look on this

:+1: Any updates on this? I'm running the Virtual Machine 5.0, Vagrant 1.7.4 on Windows 8.

The SSH command responded with a non-zero exit status.

This shows right after the text
Notice: Finished Catalog run in 92.92 seconds

I have this too.

Notice: Finished Catalog run in 678.19 seconds
The SSH command responded with a non-zero exit status.

Hello guys,

Even after adding--> vagrant ALL=(ALL) NOPASSWD:ALL to /etc/sudoers file in guest machine, I'm still getting the same error (as shown below) on mac. Any solution, hint to resolve this problem?

Error:

==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/xyz/Desktop/vagrant
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir -p /vagrant

Stdout from the command:

Stderr from the command:
sudo: no tty present and no askpass program specified

Hi Guys,

please run the below command to fix the issue.

vagrant reload --provision

i tried it worked for me.

vagrant error

can someone give me a solution

@Divyaganapathy looks like adb is not installed as root right?

yes. How do i do it?

@Divyaganapathy Either you're running adb as root and provided your vm as non-root (vagrant uses default root if not specified) or you have not provided correctly your VM.

However you should not run adb as root so you'd better set up a user and use it to provision and connect to you vm (here)

config.ssh shows command not found

Has anyone made any progress on solving this problem? In case it helps with the debug here is the log I get:

==> Vaprobash: >>> Updating Composer
==> Vaprobash: You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
==> Vaprobash: You are already using composer version 03299ff075236be27be356498d6c64def973fe41.
==> Vaprobash: >>> Setting Github Personal Access Token
==> Vaprobash: You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
==> Vaprobash: >>> Installing Global Composer Packages:
==> Vaprobash:      squizlabs/php_codesniffer:1.5.*
==> Vaprobash: Changed current directory to /home/vagrant/.composer
==> Vaprobash: You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
==> Vaprobash:                                                                                                    
==> Vaprobash:   [UnexpectedValueException]                                                                       
==> Vaprobash:   Your github oauth token for github.com contains invalid characters: "phpspec/phpspec:2.0.*@dev"  
==> Vaprobash:                                                                                                    
==> Vaprobash: require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...
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.

@Hakscat It looks like your oauth token for github is corrupted ? ^^

Thanks @catuss-a. Had to edit my auth.json inside path-to-composer/.composer/. The auth token was corrupt in there. There seems to be some section in the install script that changes the value set here every time it is run back to "phpspec/phpspec:2.0.*@dev" rather than a valid token value.

@Hakscat
step1: use putty to login server
step2: type cmd composer config -g --unset github-oauth.github.com
step3: execute cmd vagrant provision on your host

Same problem as @Hakscat, I had to chmod auth.json to prevent the corruption.

I was getting the same error. I had accidentally deleted my /tmp directory. To fix the issue I manually create /tmp directory and the error was resolved.

sudo mkdir /tmp

Hi every one i have a problem with the shared folder when i restart my Host and after running vagrant up i get any suggestion plz

screen shot 2016-02-24 at 6 48 12 pm

I think that if you have an error in your provisioning script, it will report this 'SSH command responded with non-zero exit status error' - so this issue is a bag of various issues. In my case it seems to have been caused by grunt-notify in combination with karma causing the EMFILE error (https://github.com/dylang/grunt-notify/issues/68).

I got similar issues because my Vagrant version was not supported by VirtualBox. I simply updated VirtualBox and Vagrant to the latest versions and everything worked perfectly.

I am absolutely new to this. Today I tried to install VDD following steps and instructions as described at [https://www.drupal.org/node/2008792]. First time I received a series of "problems" after running vagrant up command (attached).
vagrant-up-error.txt

Then I created a new folder, put all VDD files into it and ran a fresh vagrant up from this folder. Now I have received

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

How can I get out of this? I am on Windows 10.
Somebody please help!

emfluenceindia Did you find solution on Windows 10? I have a same problem on windows.

Hi Kisat, unfortunately I didn't have solution. I switched to XAMPP and now things look pretty good.

Hi. Thanks for your comment . I update vagrant 1.8.4 after that it is
working fine.

On Мя, 2016 7-р сар 12 at 12:42 emfluenceindia [email protected]
wrote:

Hi Kisat, unfortunately I didn't have solution. I switched to XAMPP and
now things look pretty good.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/mitchellh/vagrant/issues/1659#issuecomment-231929633,
or mute the thread
https://github.com/notifications/unsubscribe/APw_zNimxJx5txbeNlWv6SFh5LoLrHADks5qUw0ggaJpZM4Am328
.

I am using Mac. Yesterday everything worked perfectly. Since today doesn't work anymore.

vagrant -v
Vagrant 1.8.5

By vagrant up I have next problem:

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

set -e
mkdir -p /home/vagrant/projects
mount -o vers=3,udp 192.168.33.1:/Users/xxx/Projects/php5 /home/vagrant/projects
if command -v /sbin/init && /sbin/init --version | grep upstart; then
  /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=/home/vagrant/projects
fi


Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: requested NFS version or transport protocol is not supported

have the same issue here as @razbakov

I posted more detailed report in #7646

Same problem as @razbakov

Windows 7, Vagrant 1.8.5, VB 5.1.2

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

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

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

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?

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

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

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

@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).

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

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

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

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.

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.

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

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


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

@briancain I am using the latest version

Vagrant 2.0.2

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

Thanks.

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

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

Updating from 2.0.2 to 2.2.0 solved my problem

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings