I have successfully created a custom Vagrant box, based on the official ubuntu/xenial64 Vagrant box, but I get this message when I attempt to use vagrant ssh:
==> default: The machine you're attempting to SSH into is configured to use
==> default: password-based authentication. Vagrant can't script entering the
==> default: password for you. If you're prompted for a password, please enter
==> default: the same password you have configured in the Vagrantfile.
The only change to the box is to provision it with NginX. I then use...
vagrant package --vagrantfile <path_to_vagrantfile> --output nginx.box
... where <path_to_vagrantfile> is, in my case, /home/blackslate/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20170822.0.0/virtualbox/Vagrantfile. I follow this with:
vagrant box add nginx nginx.box
I then create a new directory and use vagrant init nginx to create a new instance of the box. The whole process is described in this question.
When I use vagrant up, all appears to be running as expected:
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'nginx'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: Custom_default_1503826905856_10643
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: ubuntu
default: SSH auth method: password
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /home/blackslate/repos/Vagrant/Custom
However, vagrant ssh provokes the message at the beginning of this question. When I try to ssh in manually, using "ubuntu" as the ssh user and "vagrant" as the password, I get this:
ssh ubuntu#127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:PSnauymZfKi1HIRIKfez5wAnpPFJW9h3eC+TzxiiIWA.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
ubuntu#127.0.0.1's password:
Permission denied, please try again.
ubuntu#127.0.0.1's password:
I get a similar result if I try ssh vagrant#127.0.0.1:
ssh vagrant#127.0.0.1
vagrant#127.0.0.1's password:
Permission denied, please try again.
vagrant#127.0.0.1's password:
The same is true if I open the VirtualBox GUI and talk to the VM directly.
I have tried following the instructions here, but I'm guessing that this refers to an older version of Vagrant.
I am hoping that I will be able to make changes at the package stage, so that when I distribute the custom Vagrant box to other developers, vagrant ssh just works, with no need to massage any files beforehand.
Try using the Oracle Virtual Box Manager to log in directly console instead of with ssh. Thereupon may edit the sshd config file and allow the passoword authentication. Restart SSHD service.
Related
I am trying to setup a new linux project using vagrant. I want to be able to ssh into the vagrant box with putty because it has copy paste capabilities. This is what I have done so far:
Navigated to the projects destination
In the command prompt typed
vagrant init
I changed the following in the Vagrantfile:
config.vm.box = "base"
to
config.vm.box = "ubuntu/xenial64"
I then added the following lines into the Vagrantfile:
config.vm.network "private_network", ip: "192.168.10.12"
config.ssh.username = "test"
config.ssh.password = "password"
I saved the Vagrantfile
Then in the command prompt I typed
vagrant up
This what comes up in the command prompt:
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: A newer version of the box 'ubuntu/xenial64' is available! You currently
==> default: have version '20170822.0.0'. The latest is version '20170919.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: geoserver_default_1505948268591_35426
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2201 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2201
default: SSH username: test
default: SSH auth method: password
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Authentication failure. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
test#127.0.0.1's password:password
test#127.0.0.1's password:password
default: Warning: Authentication failure. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
test#127.0.0.1's password:
test#127.0.0.1's password:
default: Warning: Authentication failure. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
test#127.0.0.1's password:vagrant
test#127.0.0.1's password:vagrant
... I want a few minutes
default: Warning: Authentication failure. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
test#127.0.0.1's password: default: Warning: Connection timeout. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
test#127.0.0.1's password:Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
I try and connect to the machine through putty with the following setting and I get a Network error: Connection timed out:
Host Name: 192.168.10.12
Port 2201
Connection Type: SSH
I try and connect to the machine through putty with the following setting and I get connect to the machine but I am prompted for a username and password:
Host Name: 127.0.0.1
Port 2201
Connection Type: SSH
The username/password combination I try is:
login as: test
password: password
I get an Access denied
login as: ubuntu
password: vagrant
I get an Access denied
How do I setup vagrant so that I can ssh in with putty?
Thank you for any and all help!
There's no test user in the VM so you cannot login with this user, you would first have to create a test user account with the password and then you will be able to connect.
The ubuntu password for this box is 95bf98670a543bcd7bdd576c. You will find this information in the box's Vagrantfile, on Mac its located under ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20170116.1.0/virtualbox/Vagrantfile
You can just remove username/password information from your Vagrantfile and you will login automatically when running vagrant ssh
At first I got this error:
Text will be echoed in the clear. Please install the HighLine or
Termios libraries to suppress echoed text.
vagrant#127.0.0.1's password:
Then I installed: HighLine
Now I only get:
vagrant#127.0.0.1's password:
I tried to use vagrant has the password.
I did not work. I tried my computer password, it also did not work.
So I have no idea what the password I am supposed to use.
All this started after I added these settings (in Vagrantfile):
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.ssh.keys_only = true
config.ssh.insert_key = true
One might ask why I am using these settings (because normally vagrant is the default username and password). The reason is because for some reason the box generate some random password and uses ubuntu has the username.
# Front load the includes
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)
Vagrant.configure("2") do |config|
config.vm.base_mac = "02357F2D68C4"
config.ssh.username = "ubuntu"
config.ssh.password = "1547c59e6cbdffd4104ad720"
config.vm.provider "virtualbox" do |vb|
vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "ubuntu-zesty-17.04-cloudimg-console.log") ]
end
end
This is found inside of: ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-zesty64/20170412.1.0/virtualbox
I tried this solution and it did not work:
vagrant asks password at only the first time 'vagrant up'
So what is the password?
What can I do so that it stops asking a password?
Vagrant 1.9.1
Local OS:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 17.04
Release: 17.04
Codename: zesty
Box: ubuntu/zesty64 (virtualbox, 20170412.1.0)
UPDATE 1
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/zesty64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/zesty64'
default: URL: https://atlas.hashicorp.com/ubuntu/zesty64
==> default: Adding box 'ubuntu/zesty64' (v20170412.1.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/ubuntu/boxes/zesty64/versions/20170412.1.0/providers/virtualbox.box
==> default: Successfully added box 'ubuntu/zesty64' (v20170412.1.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/zesty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/zesty64' is up to date...
==> default: Setting the name of the VM: -----
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 3306 (guest) => 3306 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: password
default: Warning: Connection reset. Retrying...
default: Warning: Remote connection disconnect. Retrying...
vagrant#127.0.0.1's password:
vagrant#127.0.0.1's password:
default: Warning: Authentication failure. Retrying...
vagrant#127.0.0.1's password: ==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.
Vagrant's Official documentation states that there is a default password for 'vagrant' user which is
vagrant itself .
Go to their Official Website to know more
I think you have some confusion.
config.ssh.username will reference the user to use to login, but this user must exists in the VM, you cannot decide to use your own name and it will work; if there's no corresponding user in the VM, it will not work.
Vagrant recommends to use key-based authentication rather than a password, but when you create your box (generally using packer.io) you can decide to have password authentication method.
In the case of ubuntu/zesty64 box, thats what the owner has decided to do, it has created only the ubuntu user and has decided to authenticate with a password.
If you prefer to use vagrant to login to the VM, you will first need to create the vagrant user, you can also download the public key. After you make those changes, you can repackage the box so if you want to re-use in future, all setup will be kept.
You can also look at building your own box using packer, there are tons of available templates on github that you can re-use.
Just created a new vagrant box with minimal centos 7.
I followed this guide. https://blog.engineyard.com/2014/building-a-vagrant-box
Also I have everything in place as mentioned in official vagrant guides here and here
However when I try to do vagrant up. It timeouts when trying to ssh into the box.
What might be causing this?
My network adapter in the VM is NAT.
I tried to set private network ip
config.vm.network "private_network", ip: "192.168.50.4"
I was able to ssh using this ip and vagrant as username and password. I wonder why vagrant is not able to ssh?
Here is the output of vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'my'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: my_box_default_1475351710988_24744
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> 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
And after a long time it gives this error.
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
ssh keys set using the following commands
mkdir -p /home/vagrant/.ssh
chmod 0700 /home/vagrant/.ssh
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant:vagrant /home/vagrant/.ssh
There was a bug in 1.8.5 that can explain this.
can you please upgrade to 1.8.6 ?
Have you tried using
vagrant ssh
This might help someone.
Try running ip addr command and if the network interface has no IP address assigned to it then you need to set ONBOOT to yes.
[root#localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
Then change ONBOOT=no to ONBOOT=yes
Restart the machine and run ip addr to make sure that network is started properly and an IP address is assigned to the network interface.
I've tried to wake up base VM bento/centos-67.
$ vagrant version
Installed Version: 1.8.5
Latest Version: 1.8.5
You're running an up-to-date version of Vagrant!
$ vagrant init bento/centos-6.7; vagrant up --provider virtualbox; vagrant up
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-6.7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-6.7' is up to date...
==> default: Setting the name of the VM: bento_default_1473166306806_14580
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
But in the same time I can use vagrant ssh with password vagrant.
So, what's wrong?..
Linked questions: #1
(Also reported the issue to chef)
Fix
The problem is: ~/.ssh/authorized_keys file with the public key which has 644 permissions but must be 600
$ ssh vagrant#127.0.0.1 -p 2200 # use password "vagrant"
[vagrant#localhost ~]$ chmod 600 ~/.ssh/authorized_keys
Now vagrant ssh can be used without asking.
The question is why it doesn't work from the box? What's went wrong? I have teach it how to define authorized_keys file properly? oO
Maybe this related to the vagrant bug.
It is definitely the Vagrant bug you are linking to and not the Bento box. I am the Bento box maintainer and we've dropped back to Vagrant 1.8.4 in our pipelines.
I have problems to run Vagrant with Docker. The issue is the rsync of the shared folders.
WDFM32388067A:vagranttest d022051$ vagrant up
Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
default: Vagrant will now create or start a local VM to act as the Docker
default: host. You'll see the output of the `vagrant up` for this VM below.
default:
default: Importing base box 'hashicorp/boot2docker'...
default: Matching MAC address for NAT networking...
default: Checking if box 'hashicorp/boot2docker' is up to date...
default: Setting the name of the VM: docker-host_default_1438155600426_39792
default: Clearing any previously set network interfaces...
default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Forwarding ports...
default: 2375 => 2375 (adapter 1)
default: 22 => 2222 (adapter 1)
default: Running 'pre-boot' VM customizations...
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: docker
default: SSH auth method: password
default: Warning: Connection timeout. Retrying...
default: Machine booted and ready!
==> default: Syncing folders to the host VM...
default: Installing rsync to the VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
rsync --help
Stdout from the command:
Stderr from the command:
sh: rsync: not found
default: The previous process exited with exit code 1.
default: The previous process exited with exit code 1.
From the error message it is not clear whether ssh or rsync is the issue. Maybe it is because ssh is timing out. I tried all possible ssh options but nothing did work out. For example I set an config.ssh.private_key_path but still the error message was exactly the same. Has anybody had similar issues?
I was also stuck with hashicorp/boot2docker. Moving to mitchell/boot2docker didn't help, either, but I found that
https://vagrantcloud.com/dduportal/boxes/boot2docker
works well (and is more up-to-date).