2

I have a virtual machine which I launch using following code.

kvm -m 2G -hda image.raw -hdb image.data.qcow2 -redir tcp:11180::80

How can I transfer files from a Linux host to the virtual machine?

1 Answer 1

1

You can transfer files using SCP protocol working on the same port as SSH. For that you need to redirect the port 22 on the virtual machine to a local port (2222 in this example):

kvm -m 2G -hda image.raw -hdb image.data.qcow2 -redir tcp:11180::80 -redir tcp:2222::22

and connect with ssh to that port:

ssh -p 2222 user@localhost

To transfer files you can then use scp:

scp -p 2222 file.txt user@localhost:file.txt
6
  • But it require password. How can i fix this issue? Commented Aug 30, 2016 at 8:59
  • @ankitkumar How can I know? You need to provide the correct password to your virtual machine.
    – techraf
    Commented Aug 30, 2016 at 9:01
  • 1
    Sorry i asked stupid question. i logged in successfully by passing username and entering password. Commented Aug 30, 2016 at 9:02
  • If you're automating this while at the same time increasing security, you can also turn on Public Key Authentication instead of password authentication.
    – comfreak
    Commented Aug 30, 2016 at 10:12
  • I cannot scp file and there is permission denied while i can login using the same username and passowrd.scp -p 2222 data.sql user@localhost:file.txt Commented Aug 30, 2016 at 10:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .