feeding the host ssh port into the provisioner

10 views
Skip to first unread message

steve gibson

unread,
Oct 18, 2019, 2:45:06 PM10/18/19
to Vagrant
Hi,

I'm am looking for a way to get the host port for the SSH port-forward and be able to write it in a file on the guest.

My scenario is this:
I have a multi-machine setup with 2 VMs (using vbox). Both machines need to be able to scp to each other. Since eth0 is on a private network, I cannot access one guest from the other. And because of the nature of my project, I cannot add a second network interface.
So I am looking for a way to create a /root/.ssh/config file on each guest and define the peer guest with the port that is made available on the host. The IP would be the GW of the guest

So how can I get VM1's ssh port when I am provisioning VM2 ?

Thank you.

Alvaro Miranda Aguilera

unread,
Nov 25, 2019, 4:24:47 PM11/25/19
to vagra...@googlegroups.com
hello

2 things

1. you can set the port to something known

on one VM

config.vm.network :forwarded_port, guest: 22, host: 2291, id: "ssh"


on the second VM

config.vm.network :forwarded_port, guest: 22, host: 2292, id: "ssh"


and test


2. disable the insert ssh_key so you can connect with the insecure key



config.ssh.insert_key = false


then try to login with the insecure ssh key

https://github.com/hashicorp/vagrant/blob/master/keys/vagrant



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/077d5476-dff0-4db8-9d5e-029b9ef4a0d6%40googlegroups.com.


--
Alvaro

Reply all
Reply to author
Forward
0 new messages