PDA

View Full Version : [ubuntu] ssh scp - host to sever in virtualbox



pantone186
May 6th, 2009, 09:20 PM
Hello,

I'm struggling to copy a directory over from my ubuntu host to a ubuntu server in virtualbox.

following command dosen't work, connection refused.


sudo scp -r /media/disk/wordpress user@localhost:22:/var/www


nmap on ubuntu-server gives a warning - Hostname localhost resolves to 2 IPs. Using 127.0.0.1.


not sure where i'm going wrong here. any help would be much appreciated.

EXCiD3
May 6th, 2009, 09:57 PM
check in your guest OS what your IP is first. localhost from your host os will point to that os, not your virtual machine.

pantone186
May 6th, 2009, 10:46 PM
not sure how to check what the guest os ip is?


I can connect via ssh to the guest using $ ssh -l <user> -p 2222 localhost

albinootje
May 6th, 2009, 10:51 PM
sudo scp -r /media/disk/wordpress user@localhost:22:/var/www


Are you using NAT for the guest VM or "bridged" with the host interface ?
With NAT the guest will have a 10.0.2.x ip address from within VB.
When bridge is in use it will get an ip address by DHCP from your LAN.
Please check the ip address inside the guest VM.

pantone186
May 6th, 2009, 11:16 PM
it's using nat with port forwarding.

I thought the 10.0.2.2 was for accessing host from within the guest?


How do I check the ip inside the guest vm?

albinootje
May 6th, 2009, 11:22 PM
it's using nat with port forwarding.

I thought the 10.0.2.2 was for accessing host from within the guest?

How do I check the ip inside the guest vm?

Yes, 10.0.2.2 is the host ip address within NAT on VirtualBox (and also on Qemu).
Try "ifconfig" inside your guest VM.

pantone186
May 6th, 2009, 11:43 PM
ifconfig gives

eth0 10.0.2.15

and

local loopback 127.0.0.1

albinootje
May 6th, 2009, 11:52 PM
eth0 10.0.2.15


Okay, does it work with that ?

pantone186
May 6th, 2009, 11:57 PM
no, unfortunately, the terminal just seems to hang

albinootje
May 7th, 2009, 12:15 AM
no, unfortunately, the terminal just seems to hang

In the past I had much better luck with "bridged" vs. NAT in VirtualBox.
NAT would work fine for the guest, but from the host to the guest I had problems afair.
So, if no one else can offer you a better solution, and if it's OK for you, use "bridged" to host interface in VB instead, giving the guest VM its own ip address.

pantone186
May 7th, 2009, 12:21 AM
Yes I think your right I've just been reading up on that. Looks a little harder to set up for a beginer, but never-the-less ill give it a go, it's all a good learning experience.

And thanks for the help Albinootje

albinootje
May 7th, 2009, 12:34 AM
Yes I think your right I've just been reading up on that. Looks a little harder to set up for a beginer, but never-the-less ill give it a go, it's all a good learning experience.

VirtualBox has bridge support build in since a while, since VirtualBox version 2.1 :
http://www.dedyisn.net/2009/02/new-feature-virtualbox-21-bridging-in-virtualbox-automatically/

* New Host Interface Networking implementations for Windows and Linux hosts with easier setup (replaces TUN/TAP on Linux and manual bridging on Windows)



And thanks for the help Albinootje

No problem.