In this tutorial, I’m setup vagrant ssh key pair. Generating ssh key with vagrant_rsa is private key and vagrant_rsa.pub is a public key. Log in to Virtual Machine without the password. Vagrant the essential for DevOps Roles.
The structures folder for the vagrant project as below:
Vagrant ssh key pair
The first, To create a vagrant ssh key
Using the ssh-keygen command to create the private key and public key for a vagrant.
The output private key and public key files in “/home/huupv/project/keys/.ssh” folder as below:
To configure vagrant ssh key in Vagrantfile
To add the lines in Vagrantfile file as below:
Vagrant.configure("2") do |config| config.vm.box = "centos/6" config.ssh.insert_key = false config.vm.boot_timeout = 800 config.ssh.private_key_path = ["keys/.ssh/vagrant_rsa", "~/.vagrant.d/insecure_private_key"] config.vm.provision "file", source: "keys/.ssh/vagrant_rsa.pub", destination: "~/.ssh/authorized_keys" end
- ~/.vagrant.d/insecure_private_key: You should append this default key. The use config.ssh.insert_key = false to Vagrant not generate a random key.
- config.ssh.private_key_path: Changing Insecure Key To My Own Key On Vagrant box.
Finishing, We are customizing vagrant ssh key with Private/Public key. What you need to Private key saves in the host and Public key copy authorized_keys into a vagrant box for Virtual Machine. Reference to configure vagrant ssh of the vagrant main site. Thank you for reading the DevopsRoles page!