Missing IdentityFile in vagrant ssh-config?

1,245 views
Skip to first unread message

mytes...@gmail.com

unread,
Apr 3, 2017, 10:46:50 AM4/3/17
to Vagrant
I have tried to use config.ssh.private_key_path to no avail the identityFile missing seems to cause Vagrant ssh -c to fail even if I manually setup the keys.

Any help would be great I verified file permissions and such but can't get the correct  IdentityFile  key in a newly packaged centos 7.2 updated to the latest version.

Thanks

Alvaro Miranda Aguilera

unread,
Apr 3, 2017, 2:00:00 PM4/3/17
to vagra...@googlegroups.com
Hello

The key is to be used by vagrant to ssh into the box password less

when you created this box, before packaging, were you able to ssh using this key as vagrant user?

How are you adding this parameter to Vagrantfile, and what you mean you manually setup the keys? the public key should be already inside the box, and you will use the private key.

Thanks
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/6d670716-dfa5-48c3-bca3-93024c5e85bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

mytes...@gmail.com

unread,
Apr 3, 2017, 2:26:54 PM4/3/17
to Vagrant
What appears to be happening is everything works great no issues ssh and ssh -c and config all work as expected. Then we package the box and do a vagrant add on the new box. The new box once started asks for a password:

vagrant ssh
==> test-fix: The machine you're attempting to SSH into is configured to use
==> test-fix: password-based authentication. Vagrant can't script entering the
==> test-fix: password for you. If you're prompted for a password, please enter
==> test-fix: the same password you have configured in the Vagrantfile.
ro...@127.0.0.1's password:

and the  vagrant ssh-command is now missing the identityFile.

Alvaro Miranda Aguilera

unread,
Apr 3, 2017, 2:50:33 PM4/3/17
to vagra...@googlegroups.com

On Mon, Apr 3, 2017 at 8:26 PM, <mytes...@gmail.com> wrote:
ro...@127.0.0.1's password:

can we step couple of step back?

are you using root for this? is not good practice in general

what do you want to do with this custom ssh?

If you use the known ssh key pair, vagrant will generate one on the first boot.




--
Alvaro

mytes...@gmail.com

unread,
Apr 3, 2017, 3:43:52 PM4/3/17
to Vagrant
Yes we are using root atm the box is brought up from a kickstart box then the OS is updated to the latest version of centos after the update a box file is generated for secondary work. Once the box is added then vagrant up the credentials request a password:  
vagrant ssh
==> test-fix: The machine you're attempting to SSH into is configured to use
==> test-fix: password-based authentication. Vagrant can't script entering the
==> test-fix: password for you. If you're prompted for a password, please enter
==> test-fix: the same password you have configured in the Vagrantfile.
ro...@127.0.0.1's password:

vagrant ssh-config
Host test-fix
  HostName 127.0.0.1
  User root
  Port 2200
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentitiesOnly yes
  LogLevel FATAL

I can fix the passwordless ssh no issue but not the missing identityFile which stops vagrant ssh -c from working.

vagrant ssh -c "ls"
Using `vagrant ssh -c` requires key-based SSH authentication, but your
Vagrant environment is configured to use only password-based authentication.
Please configure your Vagrantfile with a private key to use this
feature.

Note that Vagrant can automatically insert a keypair and use that
keypair for you. Just set `config.ssh.insert_key = true` in your
Vagrantfile.

Alvaro Miranda Aguilera

unread,
Apr 3, 2017, 4:09:40 PM4/3/17
to vagra...@googlegroups.com
can you share your Vagrantfile and the one that is on ~/.vagrant.d/boxes/nameofyourbox/*... there is one in this path, please include this too

I assume you are using

config.ssh.username = "root" somewhere

you you defining here the path to the private key ?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

mytes...@gmail.com

unread,
Apr 3, 2017, 5:33:00 PM4/3/17
to Vagrant
cat /mnt/storage/vagrant_home/boxes/test_wrk_keys-add-vagrant.pub.box/0/virtualbox/Vagrantfile
Vagrant::Config.run do |config|
  # This Vagrantfile is auto-generated by `vagrant package` to contain
  # the MAC address of the box. Custom configuration should be placed in
  # the actual `Vagrantfile` in this box.
  config.vm.base_mac = "080027FA80FD"
end

# Load include vagrant file if it exists after the auto-generated
# so it can override any of the settings
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)

Vagrant.configure("2") do |config|
  config.ssh.private_key_path = File.expand_path("../vagrant_private_key", __FILE__)
end



Hmmm. interesting that this  config.ssh.private_key_path = File.expand_path("../vagrant_private_key", __FILE__) is here but not in a working box.... 

On Monday, April 3, 2017 at 9:46:50 AM UTC-5, mytes...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages