Dmitry
Dmitry

Reputation: 4373

Vagrant create alias for long machine name

I'm on MacOS and when I start my vagrant box (vagrant up && vagrant ssh) I see a fairly long prompt

vagrant@vagrant-ubuntu-trusty-64

How can I shorten it? I want something like this

vagrant@box

Upvotes: 0

Views: 242

Answers (1)

BrianC
BrianC

Reputation: 10721

The simplest approach would be to define a logical name for the box (see the config.vm docs).

For example a minimal Vagrantfile might look like this:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.hostname = "web1"
end

And then the shell prompt will be user@hostname, like:

$ vagrant ssh
vagrant@web1:~$

This is also handy if you ever do multiple Vagrant VMs which have different roles, like "web" versus "db" for example.

Upvotes: 1

Related Questions