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 <shashank.kor...@gmail.com>
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
> vagrant@172.18.0.1'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+unsubscr...@googlegroups.com.
> 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/CAHqq0ewisZw3-10nuWZdNEVHbzLGV7Xj3AyARXioe-tVA%3Dgf4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to