ssh between 2 servers using their names rather than their ips

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ssh between 2 servers using their names rather than their ips

LIRAN Y

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ssh between 2 servers using their names rather than their ips

Alvaro Miranda Aguilera
Hello

the easiest way is to add a entry into /etc/hosts with other server ip name

you can use the same shell script for this.

Virusvrij. www.avast.com

On Sun, Oct 29, 2017 at 6:57 PM, LIRAN Y <[hidden email]> wrote:

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewyrBe5AF_-%2B-fLkdeq%2BosHiYzrHshgR0J7GwczWhzLKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ssh between 2 servers using their names rather than their ips

LIRAN Y
Hi Alvaro 
10x for your replay

i tried to enter this in the 
etc/host/
192.168.100.11 server2
Do i need some restart?

still it ask me for pw:

$ vagrant ssh server1
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Sun Oct 29 21:07:27 2017 from 10.0.2.2
vagrant@server1:~$ ssh server2
vagrant@server2's password:


On Monday, October 30, 2017 at 10:25:58 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello

the easiest way is to add a entry into /etc/hosts with other server ip name

you can use the same shell script for this.

<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;"> Virusvrij. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:#4453ea" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;">www.avast.com
<a href="#CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" rel="nofollow" onmousedown="this.href=&#39;#CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;" onclick="this.href=&#39;#CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;">

On Sun, Oct 29, 2017 at 6:57 PM, LIRAN Y <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="dr0V62Y_CQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">lir...@...> wrote:

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="dr0V62Y_CQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">vagrant-up+...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ssh between 2 servers using their names rather than their ips

Alvaro Miranda Aguilera
Hello there

so are different things here at play.

One is Vagrant is a tool that help you to do stuff, but what to do, or how to do it, requires the knowledge.

I will explain from the basics, in case other people came here in the future.

When you have a multi machine Vagrant file, the Vms are independent, and you have lots of moving parts and the VMs don't know each other, etc.

using names intead of ip, requires name resolution, so your Vagrantfile can use a script to populate the /etc/hosts
then to be able to ssh into, requires both machines (or more machines) to have a public/private key and allow access to those private keys.


Here is a working Vagrantifle i have just did that have all what you want to do, feel free to copy/edit
feel free to ask questions too:


gist:






numnodes=2
baseip="192.168.10"

#global script
$global = <<SCRIPT

#check for private key for vm-vm comm
[ -f /vagrant/id_rsa ] || {
  ssh-keygen -t rsa -f /vagrant/id_rsa -q -N ''
}

#deploy key
[ -f /home/vagrant/.ssh/id_rsa ] || {
    cp /vagrant/id_rsa /home/vagrant/.ssh/id_rsa
    chmod 0600 /home/vagrant/.ssh/id_rsa
}

#allow ssh passwordless
grep 'vagrant@node' ~/.ssh/authorized_keys &>/dev/null || {
  cat /vagrant/id_rsa.pub >> ~/.ssh/authorized_keys
  chmod 0600 ~/.ssh/authorized_keys
}

#exclude node* from host checking
cat > ~/.ssh/config <<EOF
Host node*
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
EOF

#populate /etc/hosts
for x in {11..#{10+numnodes}}; do
  grep #{baseip}.${x} /etc/hosts &>/dev/null || {
      echo #{baseip}.${x} node${x##?} | sudo tee -a /etc/hosts &>/dev/null
  }
done

#end script
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", privileged: false, inline: $global
  prefix="node"
  #node box
  (1..numnodes).each do |i|
    vm_name = "#{prefix}#{i}"
    config.vm.define vm_name do |node|
      node.vm.box = "hashicorp/precise64"
      node.vm.hostname = vm_name
      ip="#{baseip}.#{10+i}"
      node.vm.network "private_network", ip: ip
    end
  end
end





On Tue, Oct 31, 2017 at 8:49 AM, LIRAN Y <[hidden email]> wrote:
Hi Alvaro 
10x for your replay

i tried to enter this in the 
etc/host/
192.168.100.11 server2
Do i need some restart?

still it ask me for pw:

$ vagrant ssh server1
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Sun Oct 29 21:07:27 2017 from 10.0.2.2
vagrant@server1:~$ ssh server2
vagrant@server2's password:


On Monday, October 30, 2017 at 10:25:58 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello

the easiest way is to add a entry into /etc/hosts with other server ip name

you can use the same shell script for this.

Virusvrij. www.avast.com

On Sun, Oct 29, 2017 at 6:57 PM, LIRAN Y <[hidden email]> wrote:

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0ezYXyuw1O%3D7NG1syR%3Dj866qtegeL45FJ7A1kUr4Jc8QCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ssh between 2 servers using their names rather than their ips

LIRAN Y
Alvaro
Great thank you for the answer i will try it
another thing i am trying to enter to the ip address of the server1 http://192.168.100.10/ throw the web browser but i get "site can’t be reached 192.168.100.10 refused to connect."
i tried to set in the vagranfile instead of:
      node.vm.network "private_network", ip: machine[:ip]
i tried:
      config.vm.network "forwarded_port", guest: 80, host: 8080

but nothing change...

On Tuesday, October 31, 2017 at 11:49:01 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello there

so are different things here at play.

One is Vagrant is a tool that help you to do stuff, but what to do, or how to do it, requires the knowledge.

I will explain from the basics, in case other people came here in the future.

When you have a multi machine Vagrant file, the Vms are independent, and you have lots of moving parts and the VMs don't know each other, etc.

using names intead of ip, requires name resolution, so your Vagrantfile can use a script to populate the /etc/hosts
then to be able to ssh into, requires both machines (or more machines) to have a public/private key and allow access to those private keys.


Here is a working Vagrantifle i have just did that have all what you want to do, feel free to copy/edit
feel free to ask questions too:


gist:
<a href="https://gist.github.com/kikitux/86a0bd7b78dca9b05600264d7543c40d" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fkikitux%2F86a0bd7b78dca9b05600264d7543c40d\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFY08c3vuH1Mdsb04lohTJ-5SwI0Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fkikitux%2F86a0bd7b78dca9b05600264d7543c40d\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFY08c3vuH1Mdsb04lohTJ-5SwI0Q&#39;;return true;">https://gist.github.com/kikitux/86a0bd7b78dca9b05600264d7543c40d






numnodes=2
baseip="192.168.10"

#global script
$global = <<SCRIPT

#check for private key for vm-vm comm
[ -f /vagrant/id_rsa ] || {
  ssh-keygen -t rsa -f /vagrant/id_rsa -q -N ''
}

#deploy key
[ -f /home/vagrant/.ssh/id_rsa ] || {
    cp /vagrant/id_rsa /home/vagrant/.ssh/id_rsa
    chmod 0600 /home/vagrant/.ssh/id_rsa
}

#allow ssh passwordless
grep 'vagrant@node' ~/.ssh/authorized_keys &>/dev/null || {
  cat /vagrant/id_rsa.pub >> ~/.ssh/authorized_keys
  chmod 0600 ~/.ssh/authorized_keys
}

#exclude node* from host checking
cat > ~/.ssh/config <<EOF
Host node*
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
EOF

#populate /etc/hosts
for x in {11..#{10+numnodes}}; do
  grep #{baseip}.${x} /etc/hosts &>/dev/null || {
      echo #{baseip}.${x} node${x##?} | sudo tee -a /etc/hosts &>/dev/null
  }
done

#end script
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", privileged: false, inline: $global
  prefix="node"
  #node box
  (1..numnodes).each do |i|
    vm_name = "#{prefix}#{i}"
    config.vm.define vm_name do |node|
      node.vm.box = "hashicorp/precise64"
      node.vm.hostname = vm_name
      ip="#{baseip}.#{10+i}"
      node.vm.network "private_network", ip: ip
    end
  end
end





On Tue, Oct 31, 2017 at 8:49 AM, LIRAN Y <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ACmGsIOSCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">lir...@...> wrote:
Hi Alvaro 
10x for your replay

i tried to enter this in the 
etc/host/
192.168.100.11 server2
Do i need some restart?

still it ask me for pw:

$ vagrant ssh server1
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  <a href="https://help.ubuntu.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fhelp.ubuntu.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJVte2zfc10M61dWPfvPZedZC_xg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fhelp.ubuntu.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJVte2zfc10M61dWPfvPZedZC_xg&#39;;return true;">https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Sun Oct 29 21:07:27 2017 from 10.0.2.2
vagrant@server1:~$ ssh server2
vagrant@server2's password:


On Monday, October 30, 2017 at 10:25:58 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello

the easiest way is to add a entry into /etc/hosts with other server ip name

you can use the same shell script for this.

<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;"> Virusvrij. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:#4453ea" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;">www.avast.com
<a href="#CAHqq0ezYXyuw1O=7NG1syR=j866qtegeL45FJ7A1kUr4Jc8QCg@mail.gmail.com_m_1359795244664392617_CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" rel="nofollow" onmousedown="this.href=&#39;#CAHqq0ezYXyuw1O\x3d7NG1syR\x3dj866qtegeL45FJ7A1kUr4Jc8QCg@mail.gmail.com_m_1359795244664392617_CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;" onclick="this.href=&#39;#CAHqq0ezYXyuw1O\x3d7NG1syR\x3dj866qtegeL45FJ7A1kUr4Jc8QCg@mail.gmail.com_m_1359795244664392617_CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;">

On Sun, Oct 29, 2017 at 6:57 PM, LIRAN Y <[hidden email]> wrote:

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">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.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ACmGsIOSCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">vagrant-up+...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/66a6a810-659e-4f9f-ba2b-789ce4ab14f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ssh between 2 servers using their names rather than their ips

Alvaro Miranda Aguilera
if the port is 8080 then you need http://[ip]:8080

if you forward 80 -> 80 then you can use the ip without the port

On Wed, Nov 1, 2017 at 7:18 AM, LIRAN Y <[hidden email]> wrote:
Alvaro
Great thank you for the answer i will try it
another thing i am trying to enter to the ip address of the server1 http://192.168.100.10/ throw the web browser but i get "site can’t be reached 192.168.100.10 refused to connect."
i tried to set in the vagranfile instead of:
      node.vm.network "private_network", ip: machine[:ip]
i tried:
      config.vm.network "forwarded_port", guest: 80, host: 8080

but nothing change...

On Tuesday, October 31, 2017 at 11:49:01 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello there

so are different things here at play.

One is Vagrant is a tool that help you to do stuff, but what to do, or how to do it, requires the knowledge.

I will explain from the basics, in case other people came here in the future.

When you have a multi machine Vagrant file, the Vms are independent, and you have lots of moving parts and the VMs don't know each other, etc.

using names intead of ip, requires name resolution, so your Vagrantfile can use a script to populate the /etc/hosts
then to be able to ssh into, requires both machines (or more machines) to have a public/private key and allow access to those private keys.


Here is a working Vagrantifle i have just did that have all what you want to do, feel free to copy/edit
feel free to ask questions too:


gist:






numnodes=2
baseip="192.168.10"

#global script
$global = <<SCRIPT

#check for private key for vm-vm comm
[ -f /vagrant/id_rsa ] || {
  ssh-keygen -t rsa -f /vagrant/id_rsa -q -N ''
}

#deploy key
[ -f /home/vagrant/.ssh/id_rsa ] || {
    cp /vagrant/id_rsa /home/vagrant/.ssh/id_rsa
    chmod 0600 /home/vagrant/.ssh/id_rsa
}

#allow ssh passwordless
grep 'vagrant@node' ~/.ssh/authorized_keys &>/dev/null || {
  cat /vagrant/id_rsa.pub >> ~/.ssh/authorized_keys
  chmod 0600 ~/.ssh/authorized_keys
}

#exclude node* from host checking
cat > ~/.ssh/config <<EOF
Host node*
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
EOF

#populate /etc/hosts
for x in {11..#{10+numnodes}}; do
  grep #{baseip}.${x} /etc/hosts &>/dev/null || {
      echo #{baseip}.${x} node${x##?} | sudo tee -a /etc/hosts &>/dev/null
  }
done

#end script
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", privileged: false, inline: $global
  prefix="node"
  #node box
  (1..numnodes).each do |i|
    vm_name = "#{prefix}#{i}"
    config.vm.define vm_name do |node|
      node.vm.box = "hashicorp/precise64"
      node.vm.hostname = vm_name
      ip="#{baseip}.#{10+i}"
      node.vm.network "private_network", ip: ip
    end
  end
end





On Tue, Oct 31, 2017 at 8:49 AM, LIRAN Y <[hidden email]> wrote:
Hi Alvaro 
10x for your replay

i tried to enter this in the 
etc/host/
192.168.100.11 server2
Do i need some restart?

still it ask me for pw:

$ vagrant ssh server1
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Sun Oct 29 21:07:27 2017 from 10.0.2.2
vagrant@server1:~$ ssh server2
vagrant@server2's password:


On Monday, October 30, 2017 at 10:25:58 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello

the easiest way is to add a entry into /etc/hosts with other server ip name

you can use the same shell script for this.

Virusvrij. www.avast.com

On Sun, Oct 29, 2017 at 6:57 PM, LIRAN Y <[hidden email]> wrote:

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
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 [hidden email]m.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/66a6a810-659e-4f9f-ba2b-789ce4ab14f8%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0eyftUUAL0rQ0h1TEita3QTf%3Dq67PKUfjHFZ4gvrrAqtZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ssh between 2 servers using their names rather than their ips

LIRAN Y
The port 80 is for guest to enter the ip address from web page am i right?
where can i see the host port?


On Wednesday, November 1, 2017 at 10:16:34 AM UTC+2, Alvaro Miranda Aguilera wrote:
if the port is 8080 then you need http://[ip]:8080

if you forward 80 -> 80 then you can use the ip without the port

On Wed, Nov 1, 2017 at 7:18 AM, LIRAN Y <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="DoitarMSBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">lir...@...> wrote:
Alvaro
Great thank you for the answer i will try it
another thing i am trying to enter to the ip address of the server1 <a href="http://192.168.100.10/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F192.168.100.10%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHFpc6F5WinagAyEcSeyW9UP401vA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F192.168.100.10%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHFpc6F5WinagAyEcSeyW9UP401vA&#39;;return true;">http://192.168.100.10/ throw the web browser but i get "site can’t be reached 192.168.100.10 refused to connect."
i tried to set in the vagranfile instead of:
      node.vm.network "private_network", ip: machine[:ip]
i tried:
      config.vm.network "forwarded_port", guest: 80, host: 8080

but nothing change...

On Tuesday, October 31, 2017 at 11:49:01 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello there

so are different things here at play.

One is Vagrant is a tool that help you to do stuff, but what to do, or how to do it, requires the knowledge.

I will explain from the basics, in case other people came here in the future.

When you have a multi machine Vagrant file, the Vms are independent, and you have lots of moving parts and the VMs don't know each other, etc.

using names intead of ip, requires name resolution, so your Vagrantfile can use a script to populate the /etc/hosts
then to be able to ssh into, requires both machines (or more machines) to have a public/private key and allow access to those private keys.


Here is a working Vagrantifle i have just did that have all what you want to do, feel free to copy/edit
feel free to ask questions too:


gist:
<a href="https://gist.github.com/kikitux/86a0bd7b78dca9b05600264d7543c40d" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fkikitux%2F86a0bd7b78dca9b05600264d7543c40d\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFY08c3vuH1Mdsb04lohTJ-5SwI0Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fkikitux%2F86a0bd7b78dca9b05600264d7543c40d\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFY08c3vuH1Mdsb04lohTJ-5SwI0Q&#39;;return true;">https://gist.github.com/kikitux/86a0bd7b78dca9b05600264d7543c40d






numnodes=2
baseip="192.168.10"

#global script
$global = <<SCRIPT

#check for private key for vm-vm comm
[ -f /vagrant/id_rsa ] || {
  ssh-keygen -t rsa -f /vagrant/id_rsa -q -N ''
}

#deploy key
[ -f /home/vagrant/.ssh/id_rsa ] || {
    cp /vagrant/id_rsa /home/vagrant/.ssh/id_rsa
    chmod 0600 /home/vagrant/.ssh/id_rsa
}

#allow ssh passwordless
grep 'vagrant@node' ~/.ssh/authorized_keys &>/dev/null || {
  cat /vagrant/id_rsa.pub >> ~/.ssh/authorized_keys
  chmod 0600 ~/.ssh/authorized_keys
}

#exclude node* from host checking
cat > ~/.ssh/config <<EOF
Host node*
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
EOF

#populate /etc/hosts
for x in {11..#{10+numnodes}}; do
  grep #{baseip}.${x} /etc/hosts &>/dev/null || {
      echo #{baseip}.${x} node${x##?} | sudo tee -a /etc/hosts &>/dev/null
  }
done

#end script
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", privileged: false, inline: $global
  prefix="node"
  #node box
  (1..numnodes).each do |i|
    vm_name = "#{prefix}#{i}"
    config.vm.define vm_name do |node|
      node.vm.box = "hashicorp/precise64"
      node.vm.hostname = vm_name
      ip="#{baseip}.#{10+i}"
      node.vm.network "private_network", ip: ip
    end
  end
end





On Tue, Oct 31, 2017 at 8:49 AM, LIRAN Y <[hidden email]> wrote:
Hi Alvaro 
10x for your replay

i tried to enter this in the 
etc/host/
192.168.100.11 server2
Do i need some restart?

still it ask me for pw:

$ vagrant ssh server1
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  <a href="https://help.ubuntu.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fhelp.ubuntu.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJVte2zfc10M61dWPfvPZedZC_xg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fhelp.ubuntu.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJVte2zfc10M61dWPfvPZedZC_xg&#39;;return true;">https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Sun Oct 29 21:07:27 2017 from 10.0.2.2
vagrant@server1:~$ ssh server2
vagrant@server2's password:


On Monday, October 30, 2017 at 10:25:58 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello

the easiest way is to add a entry into /etc/hosts with other server ip name

you can use the same shell script for this.

<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;"> Virusvrij. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:#4453ea" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;">www.avast.com
<a href="#CAHqq0eyftUUAL0rQ0h1TEita3QTf=q67PKUfjHFZ4gvrrAqtZw@mail.gmail.com_m_7032674412482915201_CAHqq0ezYXyuw1O=7NG1syR=j866qtegeL45FJ7A1kUr4Jc8QCg@mail.gmail.com_m_1359795244664392617_CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" rel="nofollow" onmousedown="this.href=&#39;#CAHqq0eyftUUAL0rQ0h1TEita3QTf\x3dq67PKUfjHFZ4gvrrAqtZw@mail.gmail.com_m_7032674412482915201_CAHqq0ezYXyuw1O\x3d7NG1syR\x3dj866qtegeL45FJ7A1kUr4Jc8QCg@mail.gmail.com_m_1359795244664392617_CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;" onclick="this.href=&#39;#CAHqq0eyftUUAL0rQ0h1TEita3QTf\x3dq67PKUfjHFZ4gvrrAqtZw@mail.gmail.com_m_7032674412482915201_CAHqq0ezYXyuw1O\x3d7NG1syR\x3dj866qtegeL45FJ7A1kUr4Jc8QCg@mail.gmail.com_m_1359795244664392617_CAHqq0ewyrBe5AF_-+-fLkdeq+osHiYzrHshgR0J7GwczWhzLKA@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;">

On Sun, Oct 29, 2017 at 6:57 PM, LIRAN Y <[hidden email]> wrote:

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">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.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">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.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DoitarMSBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">vagrant-up+...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/66a6a810-659e-4f9f-ba2b-789ce4ab14f8%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/66a6a810-659e-4f9f-ba2b-789ce4ab14f8%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/66a6a810-659e-4f9f-ba2b-789ce4ab14f8%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/66a6a810-659e-4f9f-ba2b-789ce4ab14f8%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/9767f900-aaea-490a-bd20-ca5569a807a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ssh between 2 servers using their names rather than their ips

Alvaro Miranda Aguilera
Not sure if I understand, but the names in the conf say what they are:

doc:


 config.vm.network "forwarded_port", guest: 80, host: 8080

guest 80 goes to host 8080

host is your physical computer
guest is the VM

so if you go to port 8080 on the host, you will reach port 80 in the guest


that is port forwarding, ie http://localhost:8080

if you have a fixed IP in the guest then you are not using that and you can reach the services directly on the guest.

ie. ip 10.10.10.11 something running on port 80 will be  http://10.10.10.10

for this to work, the server/service int he guest need to be bind/listening to that/any ip

you can check with

netstat -anp | grep -i listen

if only says 127.0.0.0 for port 80, then port forward will work

for private_network/public_network the listen should be 0.0.0.0

depending on the webserver some configuration need to be adjusted to override the defaults, I suggest check documentation of the product.

Thanks
alvaro

Virusvrij. www.avast.com

On Wed, Nov 1, 2017 at 10:36 AM, LIRAN Y <[hidden email]> wrote:
The port 80 is for guest to enter the ip address from web page am i right?
where can i see the host port?


On Wednesday, November 1, 2017 at 10:16:34 AM UTC+2, Alvaro Miranda Aguilera wrote:
if the port is 8080 then you need http://[ip]:8080

if you forward 80 -> 80 then you can use the ip without the port

On Wed, Nov 1, 2017 at 7:18 AM, LIRAN Y <[hidden email]> wrote:
Alvaro
Great thank you for the answer i will try it
another thing i am trying to enter to the ip address of the server1 http://192.168.100.10/ throw the web browser but i get "site can’t be reached 192.168.100.10 refused to connect."
i tried to set in the vagranfile instead of:
      node.vm.network "private_network", ip: machine[:ip]
i tried:
      config.vm.network "forwarded_port", guest: 80, host: 8080

but nothing change...

On Tuesday, October 31, 2017 at 11:49:01 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello there

so are different things here at play.

One is Vagrant is a tool that help you to do stuff, but what to do, or how to do it, requires the knowledge.

I will explain from the basics, in case other people came here in the future.

When you have a multi machine Vagrant file, the Vms are independent, and you have lots of moving parts and the VMs don't know each other, etc.

using names intead of ip, requires name resolution, so your Vagrantfile can use a script to populate the /etc/hosts
then to be able to ssh into, requires both machines (or more machines) to have a public/private key and allow access to those private keys.


Here is a working Vagrantifle i have just did that have all what you want to do, feel free to copy/edit
feel free to ask questions too:


gist:






numnodes=2
baseip="192.168.10"

#global script
$global = <<SCRIPT

#check for private key for vm-vm comm
[ -f /vagrant/id_rsa ] || {
  ssh-keygen -t rsa -f /vagrant/id_rsa -q -N ''
}

#deploy key
[ -f /home/vagrant/.ssh/id_rsa ] || {
    cp /vagrant/id_rsa /home/vagrant/.ssh/id_rsa
    chmod 0600 /home/vagrant/.ssh/id_rsa
}

#allow ssh passwordless
grep 'vagrant@node' ~/.ssh/authorized_keys &>/dev/null || {
  cat /vagrant/id_rsa.pub >> ~/.ssh/authorized_keys
  chmod 0600 ~/.ssh/authorized_keys
}

#exclude node* from host checking
cat > ~/.ssh/config <<EOF
Host node*
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
EOF

#populate /etc/hosts
for x in {11..#{10+numnodes}}; do
  grep #{baseip}.${x} /etc/hosts &>/dev/null || {
      echo #{baseip}.${x} node${x##?} | sudo tee -a /etc/hosts &>/dev/null
  }
done

#end script
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", privileged: false, inline: $global
  prefix="node"
  #node box
  (1..numnodes).each do |i|
    vm_name = "#{prefix}#{i}"
    config.vm.define vm_name do |node|
      node.vm.box = "hashicorp/precise64"
      node.vm.hostname = vm_name
      ip="#{baseip}.#{10+i}"
      node.vm.network "private_network", ip: ip
    end
  end
end





On Tue, Oct 31, 2017 at 8:49 AM, LIRAN Y <[hidden email]> wrote:
Hi Alvaro 
10x for your replay

i tried to enter this in the 
etc/host/
192.168.100.11 server2
Do i need some restart?

still it ask me for pw:

$ vagrant ssh server1
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Sun Oct 29 21:07:27 2017 from 10.0.2.2
vagrant@server1:~$ ssh server2
vagrant@server2's password:


On Monday, October 30, 2017 at 10:25:58 AM UTC+2, Alvaro Miranda Aguilera wrote:
Hello

the easiest way is to add a entry into /etc/hosts with other server ip name

you can use the same shell script for this.

Virusvrij. www.avast.com

On Sun, Oct 29, 2017 at 6:57 PM, LIRAN Y <[hidden email]> wrote:

I would like to ssh between the servers using their names rather than their ips. 

for example

in order to test this, run i need to vagrant ssh server1 and from their i should be able to run ssh server2 to the second server.


i have the vagrantfile configure that way:

servers=[



{

 
:hostname => "server1",

 
:ip => "192.168.100.10",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,




},

{

 
:hostname => "server2",

 
:ip => "192.168.100.11",

 
:box => "hashicorp/precise64",

 
:ram => 512,

 
:cpu => 1,

}


]




Vagrant.configure(2) do |config|

  servers
.each do |machine|

    config
.vm.define machine[:hostname] do |node|

        machine
[:provisions].each do |script|

           node
.vm.provision :shell, :path => script

       
end

      node
.vm.box = machine[:box]

      node
.vm.hostname = machine[:hostname]

      node
.vm.network "private_network", ip: machine[:ip]

      node
.vm.provider "virtualbox" do |vb|

        vb
.memory = machine[:ram]

        vb
.cpus = machine[:cpu]

     
end

   
end

 
end

end


i tried to enter the server 1 by vagrant ssh server1

and there i did ssh server2 but it ask me for a password?

how can i enter without password?


10x

--
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 [hidden email]m.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c7500ffd-e168-4987-b1f1-16aca8219ded%40googlegroups.com.
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 [hidden email]m.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a8a85dc1-0b98-4f12-b5a6-aac402a3733b%40googlegroups.com.
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/66a6a810-659e-4f9f-ba2b-789ce4ab14f8%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/9767f900-aaea-490a-bd20-ca5569a807a2%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewf9aDGTPEhDah_%2BaCZHSY_nnjw%2Byd1bAed6aBjVr2PBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.