vagrant info
Disclaimer This plugin actually doesn't nothing more than the commands ssh-config and global-status
Installation
$ vagrant plugin install vagrant-info
Usage
This package offers two vagrant subcommands:
info-ssh
: Outputs the same output as ssh-config but with the machine id
as instead machine name in the Hostname
.
info-ssh
: Outputs a csv with the entries of machine_index, same as global-status
Tutorial
Let's guess that you have the following multi-machine Vagrantfile, inside the directory ~/some/where
:
# -*- mode: ruby -*-
Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
config.vm.define "web" do |web|
web.vm.box = "ubuntu/trusty64"
web.vm.hostname = "ubuntu"
end
config.vm.define "db" do |db|
db.vm.box = "chef/centos-6.5"
db.vm.hostname = "centos"
end
end
And you need to connect through ssh to the machine named db
Normal steps
-
Start up the machine
db
, you can choose the following options:- Go to
~/some/where
and executevagrant up db
- Check the
id
of your machine withvagrant global-status
orvagrant info-index
and executevagrant up <id>
- Go to
-
Go to
~/some/where
and executevagrant ssh db
With vagrant-info
-
(Same step 1.)
-
Execute
vagrant info-ssh <id> >> ~/.ssh/config
and the next time you can use:ssh <id>
.If you don't want to polute your
ssh_config(5)
with configurations of vagrant machines you can use a custom configfile:$ vagrant info-ssh <id> >> ~/.vagrant-sshconfig $ ssh -T ~/.vagrant-sshconfig <id>