Hi Alvaro,

This is my vagrant file and I havent set any config.vm.hostname in my 
Vagrantfile. 

When I checked the hostname on the VM , it shows as vagrant.

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true
    config.vm.box = "bento/ubuntu-16.04"
    config.vm.network "private_network", ip: '50.x.x.x'
    config.vm.provider :vmware_esxi do |v|
      v.esxi_hostname = '10.x.x.x.'
      v.esxi_username = 'root'
      v.esxi_password = 'secret'
      v.custom_vmx_settings = [['vhv.enable', 'TRUE']]
      v.vmname = test-vm
      v.memsize = 6000
      v.numvcpus = 2
      v.virtual_network = ["VM Network","VM Network"]
      #v.resource_pool = "/Vagrant"
    end
    config.vm.provision :shell do |s|
       s.path = /home/username/somescript.sh
    end
end

I bought DOWN the interface with ip 172.18.0.1 and the ssh-config now 
showed the public interface that it should have shown earlier.
No idea why this is happening.

On Friday, February 2, 2018 at 3:26:56 PM UTC+5:30, Alvaro Miranda Aguilera 
wrote:
>
> vagrant will change the hostname if there is a config.vm.hostname = 
> "something" in the Vagrantifle
>
> otherwise it shouldn't
>
> why you are running vagrant commands with sudo?
>
>
> On Thu, Feb 1, 2018 at 9:45 PM, Shashank Korada <shashan...@gmail.com 
> <javascript:>> wrote:
>
>>
>> down votefavorite 
>> <https://stackoverflow.com/questions/48570805/vagrant-ssh-config-hostname-changes-post-provisioning#>
>>
>> I am bringing up a VM using the vmware vagrant plugin and once the VM is 
>> up I run a shell script to provision the VM.
>>
>> Prior to the script that runs, following is the ssh-config and other 
>> details
>>
>> ssh-config
>>
>> sudo vagrant ssh-config
>> ==> test-vm: --- ESXi version    : VMware ESXi 6.5.0 build-4887370
>> Host test-vm
>> HostName 10.73.40.42
>> User vagrant
>> Port 22
>> UserKnownHostsFile /dev/null
>> StrictHostKeyChecking no
>> PasswordAuthentication no
>> IdentityFile /home/username/.vagrant.d/insecure_private_key
>> IdentitiesOnly yes
>> LogLevel FATAL
>> ForwardAgent yes
>>
>> With this when I run vagrant ssh it does a ssh to the VM without being 
>> prompted for a password
>>
>> sudo vagrant ssh
>>
>> ==> test-vm: --- ESXi version    : VMware ESXi 6.5.0 build-4887370
>> Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64)
>>
>> * Documentation:  https://help.ubuntu.com
>> * Management:     https://landscape.canonical.com
>> * Support:        https://ubuntu.com/advantage
>>
>> 0 packages can be updated.
>> 0 updates are security updates.
>>
>> vagrant@vagrant:~$   ===> PASSWORDLESS SSH
>>
>> Now when my shell script runs , it create certain bridge and network 
>> interfaces within the VM and post the script I see that on running 
>> ssh-config, it has a different HostName
>>
>> sudo vagrant ssh-config
>>
>> Host test-vm
>> HostName 172.18.0.1 ===> CHANGED
>> User vagrant
>> Port 22
>> UserKnownHostsFile /dev/null
>> StrictHostKeyChecking no
>> PasswordAuthentication no
>> IdentityFile /home/username/.vagrant.d/insecure_private_key
>> IdentitiesOnly yes
>> LogLevel FATAL
>> ForwardAgent yes
>>
>> Why does vagrant change the hostname. Due to this I am unable to do a 
>> passwordless ssh to the VM using 'vagrant ssh'
>>
>> sudo vagrant ssh
>> vag...@172.18.0.1 <javascript:>'s password:  ====> PASSWORD PROMPT
>>
>> Why does the HostName change here? Is there a way to do a passwordless 
>> ssh here?
>>
>>
>> Regards
>>
>> -- 
>> This mailing list is governed under the HashiCorp Community Guidelines - 
>> https://www.hashicorp.com/community-guidelines.html. Behavior in 
>> violation of those guidelines may result in your removal from this mailing 
>> list.
>>  
>> GitHub Issues: https://github.com/mitchellh/vagrant/issues
>> IRC: #vagrant on Freenode
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Vagrant" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to vagrant-up+...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/vagrant-up/acb28870-c17f-4579-8438-947924387b86%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/vagrant-up/acb28870-c17f-4579-8438-947924387b86%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Alvaro
>
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vagrant-up+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/6cc1e55b-b583-4dc4-bc9e-1a290a963d87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to