{"id":236,"date":"2012-04-09T19:18:21","date_gmt":"2012-04-09T09:18:21","guid":{"rendered":"http:\/\/helms-deep.net\/~rwh\/blog\/?p=236"},"modified":"2012-04-10T20:19:03","modified_gmt":"2012-04-10T10:19:03","slug":"rdp-virtualbox-without-the-proprietary-oracle-extension-pack","status":"publish","type":"post","link":"https:\/\/helms-deep.net\/~rwh\/blog\/?p=236","title":{"rendered":"RDP VirtualBox without the proprietary Oracle extension pack"},"content":{"rendered":"<p>These days, virtualisation is all the rage.  The various competing virtualisation products have reached a level of maturity where they can be reliably used for server consolidation.  VirtualBox is one of the easiest to use, most featureful programs available in this space and with the ability to run on many different OSes on hardware with or without VM extensions, it is also one of the most popular.  However, there is one wrinkle when it comes to using it for server consolidation: the proprietary RDP\/USB2 extension pack.<\/p>\n<p>The conventional wisdom when running a headless server with VirtualBox is that you need to install this <a href=https:\/\/www.virtualbox.org\/wiki\/Downloads>proprietary extension pack from Oracle<\/a>.  This is fine until you want to use the server in production: as the <a href=https:\/\/www.virtualbox.org\/wiki\/VirtualBox_PUEL>PUEL<\/a> only covers you for personal use and evaluation, you must <a href=\"http:\/\/www.oracle.com\/us\/technologies\/virtualization\/oraclevm\/061976.html\">purchase licenses<\/a>.  You can either pay \u00c2\u00a334 per user or \u00c2\u00a3670 per &#8220;socket&#8221; (which has quite a <a href=http:\/\/www.orafaq.com\/wiki\/Oracle_Licensing#Standard_Edition_Per-socket_licensing>convoluted definition<\/a>).  This gets you USB2 and RDP support.<\/p>\n<p>However, there is another way, at least when it comes to RDP support.<!--more-->  <a href=http:\/\/www.virtualbox.org\/manual\/ch07.html>Chapter 7 of the VirtualBox manual<\/a> covers running virtual machines on a remote host, either with <code>VBoxManage<\/code> command (which offeres similar functionality to the VirtualBox GUI) or the <code>VBoxHeadless<\/code> command, which appears to be the backend binary that <code>VBoxManage<\/code> calls out to to do the actual work.  Now, chapter 7 covers in detail how to connect to remote VMs using the proprietary extensions, but there&#8217;s one feature that they conveniently failed to mention: the built-in VNC server.<\/p>\n<pre>man VBoxHeadless\r\nVBOXHEADLESS(1)            User Commands             VBOXHEADLESS(1)\r\n\r\nNAME\r\n       VBoxHeadless - x86 virtualization solution\r\n\r\nDESCRIPTION\r\n    Oracle  VM  VirtualBox Headless Interface (C) 2008-2011 Oracle\r\n    Corporation All rights reserved.\r\n\r\nUsage:\r\n    -s, -startvm, --startvm &lt;name|uuid&gt;\r\n           Start given VM (required argument)\r\n    -n, --vnc\r\n           Enable the built in VNC server\r\n    -m, --vncport &lt;port&gt;\r\n           TCP port number to use for the VNC server\r\n    -o, --vncpass &lt;pw&gt;\r\n           Set the VNC server password\r\n    -v, -vrde, --vrde on|off|config\r\n           Enable (default) or disable the VRDE  server  or  don't\r\n           change the setting\r\n    -e,  -vrdeproperty,  --vrdeproperty  &lt;name=[value]&gt;\r\n    Set a VRDE property:\r\n           \"TCP\/Ports\" - comma-separated list of  ports  the  VRDE\r\n           server can bind to. Use a dash between two port numbers\r\n           to specify a range \"TCP\/Address\"  -  interface  IP  the\r\n           VRDE server will bind to\r\n    -c, -capture, --capture\r\n           Record the VM screen output to a file\r\n    -w, --width\r\n           Frame width when recording\r\n    -h, --height\r\n           Frame height when recording\r\n    -r, --bitrate\r\n           Recording bit rate when recording\r\n    -f, --filename\r\n           File  name when recording.  The codec used will be cho\u00e2\u20ac\u0090\r\n           sen based on the file extension\r\n\r\nVBoxHeadless                January 2011             VBOXHEADLESS(1)<\/pre>\n<p>Right!  So we can start a virtual machine and forward its root console (or main video or out-of-band console or whatever you want to call it) over the network with a VNC server.  In my example I&#8217;ll use screen to keep my VMs running when I log out.  I&#8217;ll start a couple of VMs as an example:<\/p>\n<pre lang=\"bash\">screen\r\nVBoxHeadless --startvm 'Ubuntu' --vnc --vncport 5900\r\n# hit \"ctrl-a c\" to open a new terminal within screen\r\nVBoxHeadless --startvm 'XP1' --vnc --vncport 5901 --vncpass vnc2xrdp<\/pre>\n<p>Great!  We don&#8217;t need the proprietary expansion pack to do this.  However, there are a few drawbacks to this approach:<\/p>\n<ul>\n<li>VNC sucks over slow network connections, it&#8217;d be much nicer to use the more modern RDP protocol<\/li>\n<li>You have to keep the command running so you have to use <code>screen<\/code> or <code>nohup<\/code> or equivalent, which is a bit less convenient than using <code>VBoxManage<\/code><\/li>\n<li>If the VNC server crashes (which I&#8217;ve had happen only once so far in testing, when changing screen resolution in a Windows XP guest), the whole VM goes down with it<\/li>\n<li>You need to make sure you only bind one VNC server to each port.  As far as I can tell if you try to bind a second one to a port that&#8217;s already in use, the VM still starts up but you have no way of interacting with it!<\/li>\n<\/ul>\n<p>We can actually work around the first limitation, by using the <code>xrdp<\/code> program to &#8220;translate&#8221; the VNC protocol into RDP.  I&#8217;m on Ubuntu, so I have the luxury of installing xrdp the easy way.  On the VirtualBox server machine:<\/p>\n<pre lang=\"bash\">sudo apt-get install xrdp<\/pre>\n<p>Now we configure it to use the existing VNC servers that we previously spawned with <code>VBoxHeadless<\/code>.  One neat thing here is that xrdp uses a single RDP port to manage multiple VNC connections:<\/p>\n<p>\/etc\/xrdp\/xrdp.ini<\/p>\n<pre>[globals]\r\nbitmap_cache=yes\r\nbitmap_compression=yes\r\nport=3389\r\ncrypt_level=low\r\nchannel_code=1\r\n\r\n[xrdp1]\r\nname=VBox-Ubuntu\r\nlib=libvnc.so\r\nip=127.0.0.1\r\nport=5900\r\n\r\n[xrdp2]\r\nname=VBox-XP1\r\nlib=libvnc.so\r\nusername=\r\npassword=vnc2xrdp\r\nip=127.0.0.1\r\nport=5901<\/pre>\n<p>So we have two VirtalBox VMs running, Ubuntu and XP1.  In the example above, I started the ubuntu VNC without a password, so I&#8217;ve left out the username\/password entries.  The XP1 connection is protected with the password <code>vnc2xrdp<\/code>.  You can also use the value <code>ask<\/code> and xrdp will prompt for a username\/password for connecting to VNC.  Note that VNC passwords are generally insecure, so it&#8217;d probably be best to protect the vnc ports using firewalling.  It doesn&#8217;t appear to be possible to bind the VNC server to only the loopback device (at least from the man page above).<\/p>\n<p>So now all that&#8217;s left to do is to connect to the RDP port using one of the myriad RDP clients for linux (I&#8217;m using Remmina, but there are <a href=http:\/\/en.wikipedia.org\/wiki\/Remote_Desktop_Protocol#Non-Microsoft_implementations>heaps of options<\/a>).  You can then choose the VNC connection you want xrdp to connect to and you&#8217;re away!<\/p>\n<div id=\"attachment_267\" style=\"width: 631px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/helms-deep.net\/~rwh\/blog\/wp-content\/uploads\/2012\/04\/xrdp.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-267\" src=\"http:\/\/helms-deep.net\/~rwh\/blog\/wp-content\/uploads\/2012\/04\/xrdp.png\" alt=\"\" title=\"xrdp\" width=\"621\" height=\"380\" class=\"size-full wp-image-267\" srcset=\"https:\/\/helms-deep.net\/~rwh\/blog\/wp-content\/uploads\/2012\/04\/xrdp.png 621w, https:\/\/helms-deep.net\/~rwh\/blog\/wp-content\/uploads\/2012\/04\/xrdp-300x183.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/a><p id=\"caption-attachment-267\" class=\"wp-caption-text\">xrdp login screen<\/p><\/div>\n<p>Of course, SSH local port forwarding is your friend if you&#8217;re doing any of this through firewalls or over insecure connections.  Remmina actually includes this functionality, or you can forward the remote port to your local machine with something like:<\/p>\n<pre lang=\"bash\">ssh -L 3389:localhost:3389 vboxservermachine<\/pre>\n<p>So there you are, RDP connections to remote VirtualBox VMs without the proprietary Oracle extensions; all free software!<\/p>\n<p>Have fun. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>These days, virtualisation is all the rage. The various competing virtualisation products have reached a level of maturity where they can be reliably used for server consolidation. VirtualBox is one of the easiest to use, most featureful programs available in &hellip; <a href=\"https:\/\/helms-deep.net\/~rwh\/blog\/?p=236\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[149,145,143,139,136,147,144,28,140,142,148,146,16,17,138,135,137,141],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-console","tag-consolidation","tag-extension","tag-headless","tag-linux","tag-oracle","tag-ose","tag-oss","tag-rdp","tag-screen","tag-vboxheadless","tag-vboxmanage","tag-virtual","tag-virtualbox","tag-vm","tag-vnc","tag-windows","tag-xrdp"],"_links":{"self":[{"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=236"}],"version-history":[{"count":31,"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":269,"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions\/269"}],"wp:attachment":[{"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/helms-deep.net\/~rwh\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}