LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices



Reply
 
Search this Thread
Old 09-26-2012, 04:42 PM   #1
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Rep: Reputation: Disabled
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.
 
Old 09-26-2012, 07:22 PM   #2
btncix
Member
 
Registered: Aug 2009
Location: NC, USA
Distribution: Slackware x86
Posts: 141

Rep: Reputation: 26
I'm not familiar with KVM but how are the host and guest setup - bridged, hosted, or NAT network?
 
Old 09-26-2012, 08:37 PM   #3
jefro
Guru
 
Registered: Mar 2008
Posts: 12,087

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
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.
 
Old 09-27-2012, 10:36 AM   #4
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by btncix View Post
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 View Post
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
 
Old 09-27-2012, 03:44 PM   #5
dyasny
Member
 
Registered: Dec 2007
Location: Canada
Distribution: RHEL,Fedora
Posts: 848

Rep: Reputation: 91
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
 
1 members found this post helpful.
Old 09-27-2012, 03:55 PM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095
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.
 
Old 09-28-2012, 05:00 PM   #7
btncix
Member
 
Registered: Aug 2009
Location: NC, USA
Distribution: Slackware x86
Posts: 141

Rep: Reputation: 26
see if you can ping between guest and host
 
Old 10-04-2012, 12:59 PM   #8
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
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 ?????
 
Old 10-04-2012, 03:23 PM   #9
jefro
Guru
 
Registered: Mar 2008
Posts: 12,087

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
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.
 
Old 10-04-2012, 05:58 PM   #10
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
but the problem is that my VMs don't have access to internet

Quote:
Originally Posted by jefro View Post
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.
 
Old 10-04-2012, 06:26 PM   #11
jefro
Guru
 
Registered: Mar 2008
Posts: 12,087

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
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.

Last edited by jefro; 10-04-2012 at 06:28 PM.
 
Old 10-04-2012, 06:27 PM   #12
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095
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.
 
Old 10-05-2012, 06:17 AM   #13
cultavix
Member
 
Registered: Feb 2004
Location: England
Distribution: RedHat
Posts: 39

Rep: Reputation: 15
you should try out "sshfs" it's quite good, you can even get it to auto-mount via /etc/fstab
 
Old 10-05-2012, 06:02 PM   #14
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
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 erroralthough 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

Last edited by sanaz; 10-05-2012 at 06:18 PM.
 
Old 10-05-2012, 06:24 PM   #15
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
file sharing between a virtual machine and the host machine okok Linux - Networking 3 06-21-2013 01:42 AM
Accessing files available within a virtual machine from the host machine ed.kumar Linux - Virtualization and Cloud 5 08-03-2011 04:25 PM
How to configure the serial port of my virtual machine with host machine. akram Linux - Newbie 4 07-31-2009 11:39 PM
Running virtual pc files in a virtual machine in linux ... preferably virtual box biharibong Linux - Software 4 01-21-2009 02:04 PM
How to share files between my linux virtual machine and window vista host? huy_china Linux - Newbie 8 10-07-2008 05:42 PM


All times are GMT -5. The time now is 05:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration