-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 documentation about the default insecure key, is still not updated #8058
Comments
@chrisroberts and @mitchellh Apologies if this appears obtuse. I'm on The related issues list below indicates that Vagrant private key handling is causing grief - and these issues only represent people who hang in enough to log an issue. I think the difficulty is more than with the documentation. I note that #5005 was tagged as an enhancement... should it have been closed? I think the enhancement is still required. ScenarioYou want Vagrant to insert the public keys that correspond to a list of private keys you provide. Current behaviourCurrent behaviour can be represented as this default configuration (but I don't think it is implemented like this): Vagrant.configure("2") do |config|
config.ssh.insert_key = true
...
end and this behaviour:
Desired behaviourVagrant.configure("2") do |config|
config.ssh.private_key_path = ['~/.vagrant.d/insecure_private_key',
'~/.aws/private_key']
config.ssh.insert_key = true
end and this behaviour:
Current workaroundVagrant.configure("2") do |config|
config.vm.define "ami", primary: true do |ami|
override.ssh.insert_key = false
override.ssh.username = 'vagrant'
override.ssh.private_key_path = [ '~/.vagrant.d/insecure_private_key',
'~/.aws/private_key.pem' ]
end
pub_key = `ssh-keygen -y -e -f '~/.aws/private_key.pem'`
config.ssh.insert_key = false
config.vm.provision "shell", inline: <<-EOC
echo '#{pub_key}' >> /home/vagrant/.ssh/authorized_keys
sed --in-place=.bak -r 's/^#?(PermitRootLogin|PermitEmptyPasswords|PasswordAuthentication|X11Forwarding) yes/\1 no/' /etc/ssh/sshd_config
sed --in-place=.bak '/== vagrant insecure public key$/d' /home/vagrant/.ssh/authorized_keys
sed --in-place=.bak '$!N; /^\(.*\)\n\1$/!P; D' /home/vagrant/.ssh/authorized_keys
sudo service ssh restart
EOC
end
config.vm.provision 'chef_zero' do |chef|
...
end Related:#4707 |
@MartinanderssonDotcom Is all about the workflow. If you creare your own VM or AMI using your own pair of keys you should use:
To create custom boxes or customize AMI we have the tool packer. The 2 options private_key_path is only to be used to tell vagrant with private key to use to login to the box. The insert_key is to make the publics VM a bit more secure. |
@hedgehog Vagrant gets crazy with your workaround, I guess it's related to first sed command |
Fixes #8058: Improve wording for config.ssh.insert_key docs
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. |
On December 24th, 2014, user @gou1 made a comment on #5059 that the documentation for
config.ssh
is misleading. This caused @gildegoma to toggle some tags and rename the issue to Vagrant documentation about default insecure key should be updated.On July 7th, 2015, the issue was closed and subsequently locked.
But, the documentation was never updated. It is still misleading.
config.ssh.insert_key
docs say that this option is true/enabled, by default.But..
This sentence is kind of troublesome and my biological parser is either buggy or the exception is legit. Compare these different flavors of this sentence:
true if you do (not a) or b
true if you do not (a or b)
I vote for the latter:
config.ssh.insert_key
"has no effect" if the Vagrant user is "relying on the default insecure key".Scroll up a little bit up on the page. This is what
config.ssh.private_key_path has to say
:So by default, Vagrant use an "insecure private key", which the first section we looked claim will render his default "true" value useless. Which option overrides the other - so to speak? Either Vagrant will use the insecure private key, or he will insert a newly generated key. Both can not be true.
Also note that the
config.ssh.insert_key
section say that Vagrant use two keys (a "keypair") to replace just 1.I think that these sections need to be reworked. I also think that the community will benefit if Vagrant addressed SSH and SSH security in more detail. Currently, we have basically only 1 page that target each and every setting in
config.ssh
one after another in a list-like fashion without providing the user with an introduction/overview.The text was updated successfully, but these errors were encountered: