{"id":44275,"date":"2023-08-31T14:05:41","date_gmt":"2023-08-31T14:05:41","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=44275"},"modified":"2023-08-31T14:05:41","modified_gmt":"2023-08-31T14:05:41","slug":"transfer-file-virtualbox-vm-host","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2023\/08\/transfer-file-virtualbox-vm-host\/","title":{"rendered":"How to Transfer file between VirtualBox VM &#038; Host without Shared Folders"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/virtualbox-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-44276\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/virtualbox-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/virtualbox-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/virtualbox-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/virtualbox-logo-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/virtualbox-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/virtualbox-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>Shared Folders feature does not work for your OS in VirtualBox Virtual Machine? Here&#8217;s a quick workaround to transfer files between host and VMs.<\/p>\n<p>VirtualBox has port forwarding feature that allows to access a service or an app running in VM from the host or even the internet. With it, you can setup a quick http or ftp server in VM, then access the files outside. Or, use scp command to transfer files.<\/p>\n<h3>Step 1: Configure Port forwarding<\/h3>\n<p>Firstly, shutdown your virtual machine. Then, open its &#8216;<b>Settings<\/b>&#8216;. In pop-up dialog, navigate to &#8216;Network&#8217; -&gt; Adapter 1 -&gt; Advanced -&gt; Port Forwarding.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-networksettings.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44277\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-networksettings-600x472.webp\" alt=\"\" width=\"600\" height=\"472\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-networksettings-600x472.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-networksettings-300x236.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-networksettings.webp 740w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>In next &#8220;Port Forwarding Rules&#8221; dialog, click the right-corner icons to add\/remove rules. Then, set host port and corresponding guest port.<\/p>\n<ul>\n<li>For example, if you want to SSH or SCP to VM, then add a rule and set guest port to 22 (<i>if default SSH port in use<\/i>) and set host port to whatever that&#8217;s not in use.<\/li>\n<li>In my case, I want to set up a temporary Python http server, then access from the host, so I added a rule and set both host and guest ports to 8000.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-port-forwarding.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44278\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-port-forwarding-600x406.webp\" alt=\"\" width=\"600\" height=\"406\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-port-forwarding-600x406.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-port-forwarding-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/vb-port-forwarding.webp 682w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Step 2: Setup a temporary http server to transfer files<\/h3>\n<p>Python is pre-installed in most Linux. It has a built-in script, allows to quickly setup a http server via a single command.<\/p>\n<p>Just, boot your Linux Virtual Machine. Then, right-click on your desired folder and select &#8220;Open in Terminal&#8221; or &#8220;Open Terminal Here&#8221;. Finally, run command to setup a simple http server on VM:<\/p>\n<pre>python3 -m http.server<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/pythonhttp.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44279\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/pythonhttp-600x278.webp\" alt=\"\" width=\"600\" height=\"278\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/pythonhttp-600x278.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/pythonhttp-300x139.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/pythonhttp-768x356.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/pythonhttp.webp 894w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Finally, in host machine, open up a web browser and go to <b>localhost:8000<\/b>. Then, you can access (download) all files under that folder in the VM.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/localhost8000.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44280\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/localhost8000-600x356.webp\" alt=\"\" width=\"600\" height=\"356\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/localhost8000-600x356.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/localhost8000-300x178.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/localhost8000-768x455.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/localhost8000.webp 1304w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>If you want to create a temporary http server with upload support, then install <code>uploadserver<\/code> module in your VM via command:<\/p>\n<pre>pip install uploadserver<\/pre>\n<p>In some Linux, you may add <code>--break-system-packages<\/code> flag. So the command will be:<\/p>\n<pre>pip install uploadserver --break-system-packages<\/pre>\n<p>Then start the http server with upload feature by running command:<\/p>\n<pre>python3 -m uploadserver<\/pre>\n<p>Finally, in host go to <b>localhost:8000\/upload<\/b> to upload files to VM.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/fileupload.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44281\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/fileupload-600x285.webp\" alt=\"\" width=\"600\" height=\"285\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/fileupload-600x285.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/fileupload-300x142.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/fileupload-768x365.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/fileupload.webp 1076w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Step 3: (Optional) Use SSH\/SCP<\/h3>\n<p>For choice, you can also use secure shell (SSH) protocol to access your VM. In the case, you need to map port 22 in guest to any unused port (8088 in my case) in host.<\/p>\n<p>SSH is available in most Linux repository, and Windows can install it from Settings -&gt; Apps -&gt; Optional Features -&gt; Add a feature -&gt; OpenSSH Server.<\/p>\n<p>By running SSH server in VM, host machine can run the command below to access it:<\/p>\n<pre>ssh -p 8088 jim@localhost<\/pre>\n<p><i>Replace port number 8088, and VM&#8217;s username <code>jim<\/code> to yours<\/i>.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/ssh-vm.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/ssh-vm-600x407.webp\" alt=\"\" width=\"600\" height=\"407\" class=\"aligncenter size-large wp-image-44282\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/ssh-vm-600x407.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/ssh-vm-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/ssh-vm-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/ssh-vm.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Or, use scp command to transfer files between host and VM. For example, send &#8216;Sigil-2.0.1.tar.gz&#8217; package in host&#8217;s Downloads folder to VM user jim&#8217;s home directory:<\/p>\n<pre>scp -P 8088 \/home\/ji\/Downloads\/Sigil-2.0.1.tar.gz jim@localhost:<\/pre>\n<p>Or send &#8216;Sigil-2.0.1.tar.gz&#8217; from VM user jim&#8217;s home directory to current directory in host machine:<\/p>\n<pre>scp -P 8088 jim@localhost:~\/Sigil-2.0.1.tar.gz .\/<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/scp-vbox-vm.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/scp-vbox-vm-600x295.webp\" alt=\"\" width=\"600\" height=\"295\" class=\"aligncenter size-large wp-image-44283\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/scp-vbox-vm-600x295.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/scp-vbox-vm-300x148.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/scp-vbox-vm-768x378.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/08\/scp-vbox-vm.webp 1083w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Shared Folders feature does not work for your OS in VirtualBox Virtual Machine? Here&#8217;s a quick workaround to transfer files between host and VMs. VirtualBox has port forwarding feature that allows to access a service or an app running in VM from the host or even the internet. With it, you can setup a quick [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":44276,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[38],"class_list":["post-44275","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-virtualbox"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=44275"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44275\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/44276"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=44275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=44275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=44275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}