Book Image

Creating Development Environments with Vagrant

By : MICHAEL KEITH PEACOCK
Book Image

Creating Development Environments with Vagrant

By: MICHAEL KEITH PEACOCK

Overview of this book

Table of Contents (17 chapters)
Creating Development Environments with Vagrant Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Connecting to the multiple virtual machines over SSH


When our multiple machines boot up in our multimachine project, Vagrant automatically maps different ports from our host machine to the SSH ports on the various guest machines.

Let's take a look at the console output when booting a Vagrant project with two virtual machines within it:

As shown in the preceding screenshot, Vagrant maps the SSH port on the virtual machine designated server1 to port 2222 on the host machine, and the SSH port of the machine designated server2 to the port 2200.

This gives us the opportunity of simply using the standard SSH command from a terminal (or the likes of PuTTY on a Windows machine), to connect to localhost with the port number that Vagrant assigns to each machine.

To connect to the machine that is mapped to port 2200, we simply run the ssh vagrant@localhost –p2200 command. The –p2200 option tells the command to use a nonstandard port, and specifies the port we wish to use, in this case 2200.

Alternatively...