LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   copying files from host to virtual machine (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/copying-files-from-host-to-virtual-machine-4175429178/)

sanaz 09-26-2012 03:42 PM

copying files from host to virtual machine
 
Hi all,

I have 2 VMs created by kvm and I want to copy a file from my host to virtual machines. I googled a lot, but nothing was found. Both host and vms are running linux
Anyone knows how to do that?

Any help is appreciated.
Thanks.

btncix 09-26-2012 06:22 PM

I'm not familiar with KVM but how are the host and guest setup - bridged, hosted, or NAT network?

jefro 09-26-2012 07:37 PM

One might use the normal ways one might use between two real computers. That would be usb flash drive or network like ftp. In many vm's one can also use special folders or guest type features to move transparent to the user.

sanaz 09-27-2012 09:36 AM

Quote:

Originally Posted by btncix (Post 4790204)
I'm not familiar with KVM but how are the host and guest setup - bridged, hosted, or NAT network?

I'm not quite sure. When I open connection details in virt-manager, I see different options:
br0(Bridge br0): which its state is active and its has a tatic IPv4
lo(Ethernet lo): which its state is active and its IP is 127.0.0.1/8
p13p1(Ethernet p13p1): hich its state is active and its IP is exactly the same as IP in br0.



Quote:

Originally Posted by jefro (Post 4790240)
One might use the normal ways one might use between two real computers. That would be usb flash drive or network like ftp. In many vm's one can also use special folders or guest type features to move transparent to the user.

I can't use usb flash in my network

dyasny 09-27-2012 02:44 PM

scp comes to mind, in case the host and the guest can see each other on the network.

If you really must inject files into the guest FS, take a look at the libguestfs utilities

TobiSGD 09-27-2012 02:55 PM

I usually use rsync to copy files to/from my VMs, it normally works regardless if the VM is set up bridged or with NAT. Just install rsync on the host and the guests and use it to copy the files.

btncix 09-28-2012 04:00 PM

see if you can ping between guest and host

sanaz 10-04-2012 11:59 AM

In order to use scp how can I specify VM?

My VMs are not connected to internet so I cannot install rsync on them.

How can I ping them?
$ ping VMname ?????

jefro 10-04-2012 02:23 PM

Ping may be blocked so it is a poor choice.

Use IP address to connect via some open protocol. ssh user@192.168.1.1 for example.

sanaz 10-04-2012 04:58 PM

but the problem is that my VMs don't have access to internet

Quote:

Originally Posted by jefro (Post 4797407)
Ping may be blocked so it is a poor choice.

Use IP address to connect via some open protocol. ssh user@192.168.1.1 for example.


jefro 10-04-2012 05:26 PM

A connection to a VM is not usually dependent upon ability to access the internet. I assume you mean you have a host computer and a client vm on the same hardware.

A vm is a client computer connected to the host if you configured it to have one of the choices such as bridged or nat.

If you mean no internet to mean you don't have any network support or only local vm network then you have to use other means. Or you have to change it from local only/no network to bridged or nat.

Other ways are shared resources such as found in guest additions. It may be possible to use other means like com port or such.

TobiSGD 10-04-2012 05:27 PM

Do I understand you correctly? You have several VMs running on a host. You want to copy files from the host to the VMs (or vice versa).
Why do you think you need Internet for that? If you have a SSH server running on the VMs (which I think since you want to use scp) you simply can copy from the host to the guests. Please specify where exactly you have problems. Also specify how you usually connect to the guests (SSH, web-interface, ...) to administer them.

cultavix 10-05-2012 05:17 AM

you should try out "sshfs" it's quite good, you can even get it to auto-mount via /etc/fstab

sanaz 10-05-2012 05:02 PM

I mentioned access to internet because rsync was suggested and for installing rsync I need internet.

I'm connecting to my VM using "virsh console id".

When I'm trying to ssh my host inside my VM, I got this error:(although everything seems fine)

ssh_exchange_identification: Connection closed by remote host

when I'm trying from host to VM
ssh guest@128.197.12.30
I got this error:
Code:

/etc/ssh/ssh_config: line 62: Bad configuration option: X11UseLocalhost
/etc/ssh/ssh_config: terminating, 1 bad configuration options

I tried ssh with both uselocalhost yes and uselocalhost no

I also tried sshfs, I got this error:
Code:

read: Connection reset by peer
fusermount: failed to open current directory: Permission denied

and when I tried with sudo
Code:

fuse: bad mount point `mountkvm/': Permission denied

TobiSGD 10-05-2012 05:24 PM

You have misconfigured your SSH. Until you fix that you won't be able to connect with SSH.


All times are GMT -5. The time now is 11:35 PM.