SCP into Vagrant Box.

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

SCP into Vagrant Box.

Chaitanya Sharma
Hey!

I'm trying to scp files from host machine to vagrant vm.
Are there any easy ways to do this ?

Although a quick google search or looking up vagrant docs didn't help.
Any help is really appreciated. Thanks!

-Chaitanya
 

--
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].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: SCP into Vagrant Box.

Adam Feuer
Chaitanya,

Set the box to have a known IP address using config.vm.network and scp to the IP address. For instance, see http://docs.vagrantup.com/v2/networking/private_network.html

cheers
adam


On Thu, Apr 11, 2013 at 9:30 AM, Chaitanya Sharma <[hidden email]> wrote:
Hey!

I'm trying to scp files from host machine to vagrant vm.
Are there any easy ways to do this ?

Although a quick google search or looking up vagrant docs didn't help.
Any help is really appreciated. Thanks!

-Chaitanya
 

--
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].
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Adam Feuer <[hidden email]>

--
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].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: SCP into Vagrant Box.

Aaron Aaron
In reply to this post by Chaitanya Sharma
If you haven't done anything special to networking, then your VM is on your localhost address, so just scp to the vagrant user's account, with the 2222 port.

vagrant up
...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)

That shows what  local port you're forwarding. So then, on the host:

scp -P 2222 someFile vagrant@localhost:.

Or if you want to copy something down, run this on the host:

scp -P 2222 vagrant@localhost:someFile .

I think you can get the running VM's IP like this:

vboxmanage showvminfo tmpPrecise_1365731043 |grep "^NIC"
NIC 1:           MAC: 080027129698, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0):   name = ssh, protocol = tcp, host ip = , host port = 2222, guest ip = , guest port = 22
NIC 2:           disabled
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled

Notice the line that starts "NIC 1 Rule." I think "guest ip = ," with nothing in front of the comma, means that your guest is running on localhost. If it were running on a specific IP I think it would be there.

If you take Adam's suggestion and set a specific IP, then run the above command and see if you get that information.

On Thursday, April 11, 2013 10:30:59 AM UTC-6, Chaitanya Sharma wrote:
Hey!

I'm trying to scp files from host machine to vagrant vm.
Are there any easy ways to do this ?

Although a quick google search or looking up vagrant docs didn't help.
Any help is really appreciated. Thanks!

-Chaitanya
 

--
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].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: SCP into Vagrant Box.

Diego Zamboni
Apart from what Aaron said, please note that unless you specifically want scp for some reason, the easiest way to transfer files from the host to the VM is to just put them in the same directory as the Vagrantfile - that directory is automatically mounted under /vagrant in the VM so you can copy or use them directly from the VM.

--Diego

On Apr 11, 2013, at 9:04 PM, Aaron Aaron <[hidden email]> wrote:

If you haven't done anything special to networking, then your VM is on your localhost address, so just scp to the vagrant user's account, with the 2222 port.

vagrant up
...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)

That shows what  local port you're forwarding. So then, on the host:

scp -P 2222 someFile vagrant@localhost:.

Or if you want to copy something down, run this on the host:

scp -P 2222 vagrant@localhost:someFile .

I think you can get the running VM's IP like this:

vboxmanage showvminfo tmpPrecise_1365731043 |grep "^NIC"
NIC 1:           MAC: 080027129698, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0):   name = ssh, protocol = tcp, host ip = , host port = 2222, guest ip = , guest port = 22
NIC 2:           disabled
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled

Notice the line that starts "NIC 1 Rule." I think "guest ip = ," with nothing in front of the comma, means that your guest is running on localhost. If it were running on a specific IP I think it would be there.

If you take Adam's suggestion and set a specific IP, then run the above command and see if you get that information.

On Thursday, April 11, 2013 10:30:59 AM UTC-6, Chaitanya Sharma wrote:
Hey!

I'm trying to scp files from host machine to vagrant vm.
Are there any easy ways to do this ?

Although a quick google search or looking up vagrant docs didn't help.
Any help is really appreciated. Thanks!

-Chaitanya
 


--
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].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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].
For more options, visit https://groups.google.com/groups/opt_out.