---
title: "Explicitly ssh into vagrant machine"
description:
  "Sometimes one need to explicitly ssh into vagrant machines. This blog
  discusses how to get that done."
canonical_url: "https://www.bigbinary.com/blog/explicitly-ssh-into-vagrant-machine"
markdown_url: "https://www.bigbinary.com/blog/explicitly-ssh-into-vagrant-machine.md"
---

# Explicitly ssh into vagrant machine

Sometimes one need to explicitly ssh into vagrant machines. This blog discusses
how to get that done.

- Author: Neeraj Singh
- Published: December 27, 2015
- Categories: Misc

After building vagrant machine the command to ssh into the guest machine is
pretty simple.

```plaintext
vagarnt ssh
```

While working with chef I needed to explicitly ssh into the vagrant machine. It
took me sometime to figure it out.

The key is command `vagrant ssh-config`. The output might look like this.

```plaintext
$ vagrant ssh-config
Host vmachine
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/nsingh/code/vagrant-machine/.vagrant/machines/vmachine/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes
```

Open `~/.ssh/config` and paste the output at the end of the file and save the
file.

Now I can ssh into vagrant machine using ssh command as shown below.

```plaintext
ssh vmachine
```

If you are wondering from where the name `vmachine` came then this is the name I
had given to
[my vagrant machine](https://github.com/bigbinary/vagrant-machine/blob/f5257dc088dfdf07c73e57130425c28a363dc399/Vagrantfile#L17)
.

## Links

- [Human page](https://www.bigbinary.com/blog/explicitly-ssh-into-vagrant-machine)
