Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Hostname Vagrant

I've setup two vagrant VMs of ubuntu - one for slave and one for master.I frequently get confused after logging into the vagrant VM using vagrant ssh which machine I'm in. What do I call this green string in the screenshot and how do I change this this for both slave and master machines like ubuntuslave and ubuntumaster?

enter image description here

like image 995
Sukumar Avatar asked Jun 11 '26 00:06

Sukumar


1 Answers

The string in green is of the format <username>@<hostname>. So in order to differentiate between your two servers, you need to change the hostname, to give you something like ubuntu@ubuntu-slave.

To do this, you need to add the hostname configuration option to your Vagrantfile:

Vagrant.configure("2") do |config|
   config.vm.box = "precise32"
   config.vm.hostname = "ubuntu-slave"
   config.vm.network :private_network, ip: "192.168.0.10"
end

This, however, will only update your hostname after you recreate the VMs. If you aren't planning on doing this, you will also need to modify the hostname within Ubuntu itself.

like image 137
Derek Brown Avatar answered Jun 13 '26 20:06

Derek Brown



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!