Reputation: 5011
I have a strange problem with vagrant ssh
. Similar questions, like Vagrant asks for password after SSH key update, or (vagrant & ssh) require password, or Vagrant ssh authentication failure do not help me.
So, the plot.
I have a virtual machine running Ubuntu 14.04.3. All setup was made according to this article: https://blog.engineyard.com/2014/building-a-vagrant-box.
Note: I can ssh to this virtual machine using Putty with vagrant's insecure_private_key (converted to *.ppk), which is located "C:/Users/Gino/.vagrant.d/insecure_private_key. Password is not promtped.
Then I packaged this virtual machine, init vagrant with this package and ran vagrant up
. I got "Warning: Authentication failure. Retrying...
" error. But nevertheless I could vagrant ssh
to this machine, but it asked me a password. And if I tried to ssh
to it using Putty with the necessary key (as in the first paragraph), it asked me for a password too.
I vagrant halt
ed this machine, found it in VirtualBox VM's list and ran it manually. After that I tried to ssh
to this machine using Putty with the same key and succeed - I could logon without any password.
Result of vagrant ssh-config
, if needed:
h:\VagrantBoxes\main-server32>vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "C:/Users/Gino/.vagrant.d/insecure_private_key"
IdentitiesOnly yes
LogLevel FATAL
My Vagrantfile
(it was generated automatically, almost nothing there, only a suggested line from comments was added):
Vagrant.configure(2) do |config|
config.vm.box = "vagrant-main-server32"
config.ssh.insert_key = false
end
So what's the mystery here? Why ssh
using key works without vagrant up
and fails and prompts for password with it?
Note. Another funny thing: it still can not authenticate during
vagrant up
. But if at the time when errors "authentication failure" appear I log in to vm through virtualbox, it also succeed to log in in the window withvagrant up
. And thenvagrant ssh
works.
Upvotes: 11
Views: 13467
Reputation: 1359
This happened to me when I tried to setup ubuntu/trusty64
on Windows 11
I firstly downloaded the Vagrant box ubuntu/trusty64
and initialized it using those commands:
vagrant box add ubuntu/trusty64
vagrant init ubuntu/trusty64
vagrant up
then when I tried to ssh into it by running vagrant ssh
, it prompted me for a password:
Tofa7a@Tofa7a-PC MINGW64 ~/Desktop/VagrantProjects/ubuntu/shared
$ vagrant ssh
[email protected]'s password:
a quick solution is to log in using this password vagrant
, as noted in the Vagrant Documentation:
Root Password: "vagrant"
Vagrant does not actually use or expect any root password. However, having a generally well known root password makes it easier for the general public to modify the machine if needed.
Publicly available base boxes usually use a root password of "vagrant" to keep things easy.
Upvotes: 0
Reputation: 400
I had the same issue of vagrant requesting password. To solve it I had to
ssh-keygen
and when prompted save the key to .vagrant/machines/default/libvirt/private_key.pub
(on your Vagrantfile directory)vagrant ssh-config
and run ssh-copy-id -i .vagrant/machines/default/libvirt/private_key -p PORT vagrant@IP
(replace your PORT and IP). When prompted don't give it a passphraseAfter that you should be able to login without being prompted for password
Upvotes: 0
Reputation: 1
I had the same issue, getting [email protected]'s password
: when starting up vagrant, after inputting the supposed password [vagrant]
, I could connect to the VM. However, after reading through other solutions, I tried ssh-agent
on the same directory where the vagrantfile that was initiated is, and vagrant-ssh
, and I am able to connect to the running instance.
Upvotes: -1
Reputation: 4016
If you saved your Vagrantfile on an external HardDrive and use exfat because you are working cross platform like me, you will also encounter this error. Since exfat does not save permissions, ssh will always think that the private keys permission is 777 => to open.
I put together this script as a workaround which runs on powershell and bash (so compatible with Linux, Mac and Windows):
# ssh-agent # uncomment if your ssh-agent isn't running as a service
cat V:\vm\arch_template\.vagrant\machines\default\virtualbox\private_key | ssh-add -
ssh -p 2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no vagrant@localhost
It requieres a working ssh-agent configuration. Also pay attantion to the correct port! Vagrant changes it to a different port if 2222 isn't availabe during vagrant up
.
Upvotes: 0
Reputation: 767
I had this old setting at the top of ~/.ssh/config
.
PubkeyAcceptedKeyTypes ssh-dss,ssh-rsa
After removing it, vagrant ssh
stopped asking for password.
Upvotes: 0
Reputation: 164
I had the same issue with vagrant 1.8.1, on several boxes I use (ie: geerlingguy/centos6)
I didn't have any problem with Vagrant 1.7 on those boxes.
After some research on why i could not ssh in that box, it appears that /home/vagrant on the box had 755 permissions and ssh prevent authentication to user with those permissions
extract of /var/log/secure:
Jan 28 15:11:36 server sshd[11721]: Authentication refused: bad ownership or modes for directory /home/vagrant
To fix that vm, I only have to change the permissions /home/vagrant (did a chmod 700 on it) and now i can ssh directly into my boxes
I don't knwo how to fix it directly I think you should modify your box directly
Hope this helps!
edit: I thought it was a shared folder from the host but it's /vagrant that is shared not /home/vagrant
Upvotes: 5