There was a question last week on the VMTN community forums about generating a shortcut URL to a virtual machine's remote console in the new vSphere 5 Web Client. For those of you who have used the vCenter's Web Access may recall the option to generate a desktop shortcut to a particular virtual machine's remote console which includes ability to obfuscate the generated URL that could then be provided to your users.

With the updated vSphere 5 Web Client, there is not an option to generate the remote console URL but there is a link that you could manually copy and provide to your users. This of course is not ideal but after a tinkering, I was able to figure out how to generate the remote console URL for any virtual machine in the new vSphere 5.x Web Client.

I also created a vSphere SDK for Perl script awhile back called generateVMRemoteConsoleURL.pl which helps users automate the URL generation for vSphere 4.x environments, it has now been updated to support vSphere 5.

Here is an example of what the URL looks like for vSphere 5.0:

https://reflex.primp-industries.com:9443/vsphere-client/vmrc/vmrc.jsp?vm=EE26E7F6-591B-4256-BD7A-402E5AC9E0A8:VirtualMachine:vm-1506

Here is an example of what the URL looks like for vSphere 5.1 & 5.5:

https://reflex.primp-industries.com:9443/vsphere-clien/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:vm-1506:EE26E7F6-591B-4256-BD7A-402E5AC9E0A8

There are basicallythree important components to the URL:

  • Hostname of the vCenter Server - reflex.primp-industries.com
  • The vCenter instanceUUID which used to uniquely identify a vCenter Server - EE26E7F6-591B-4256-BD7A-402E5AC9E0A8
  • The MoRef ID of the virtual machine - vm-1506

Since the Web Client does not support URL customization, you only need to provide the name of a virtual machine to the generateVMRemoteConsoleURL.pl script and the URL will be generated for you.

Here is an example execution of the script:

Now you can take the URL output from the script and enter it into a supported web browser. You will then be asked to authenticate before it allows you to access the remote console of a particular virtual machine.

You can now provide links to specific virtual machines

63 thoughts on “How to Generate VM Remote Console URL for vSphere 5.x Web Client

  1. Hi William, thanks for that. Do you know how these URLs can be pre-authenticated or how user credentials can be passed as parameters to the URLs (so that we can integrate single sign on with external systems)?

  2. @Ashley,

    I took a quick look but haven’t been able to find a way. Using firebut, I noticed the following URL – https://reflex.primp-industries.com:9443/vsphere-client/vmrc/ticket.jsp?nonce=25e206b6-ef45-49e3-a5a0-84d9f2fc8117&_=1318485964250

    where 25e206b6-ef45-49e3-a5a0-84d9f2fc8117 is the mks ticket acquired for a particular VM and 1318485964250 is some type of counter

    You may want to file an SR to VMware to see if it’s possible to per-authenticate using mks ticket

    • Hi William,

      I am trying to generate VM REMOTE CONSOLE URL for vCenter 6.0 to access the VM CONSOLE from web browser but I am not able to end up correctly.
      Can you help on this.

      Thanks in advance.

      Thanks and Regards,
      Sathya Prabhu Ravi

  3. @Ashley,

    I spoke with engineering and it looks like it is not possible today to pre-auth VMRC. I’ve provided your feedback and this is something they can look into.

  4. @William, thanks a lot for that. Our developers have been able to get around the issue by programatically creating a clone session and using this clone session (with some trickery) to generate an Ajax call to the console page. From the POC code I’ve seen, it should be OK for now until this functionality is officially supported. It gives us the benefit of stopping the users navigating off the console web page, and allowing us to integrate our single signon technologies (using a proxied vCentre logon for console access).

  5. @Ashley, I have a doubt & I need to get in touch with you regarding that. Can I have your email id or twitter handle or FB vanity URL? My twitter & FB id is pprakash.

    Thanks,
    Prakash

  6. @Jason,

    No I’m afraid not. A VM display name is not always unique & standardizing on something such as a MoRef ID guarantees uniqueness + readability.

  7. Hello,
    I’m trying to get your script running but I keep getting the following error about a missing perl lib :
    Can’t locate VMware/VILib.pm in @INC
    I did a search on CPAN and I couldn’t find it
    According to vmware documentation, that lib is supposed to be included into the : vsphere sdk perl, I installed it but still getting the same error?
    also perl -e ‘use VMware::VILib;’ gives the same error, could you point me please where to get that lib ?
    //using Linux Ubuntu Desktop.

  8. Is there any update on @Ashley’s query on pre-authenticated VMRC.

    It would really helpful if you can help us on that.

    Thanks ,
    Anand

  9. @William,

    Thanks for your prompt reply..Just like to know whether there are any api exposed to know whether web client server is running inside vcenter ?

  10. William, is there a way to provide end user access to the local resources using only the console window (like we could with the old Web Client), such as the CD/DVD-ROM, the floppy and now USB devices?

    • The below shorcut works to provide the old console like from 4.x for me on 5. This should give you local resource access.

      “C:\Program Files (x86)\Common Files\VMware\VMware VMRC Plug-in\Internet Explorer\vmware-vmrc.exe” -h vsphere5:443 -M vm-400

    • BryanMcC, on a clean install without a previous version of the older Web client with vmware-vmrc.exe, how would you do it? Is there somewhere you are downloading a V5 verison of that plug-in? I did test it on an older 32-bit machine I’ve been using with versions of VMware ESX as far back as 2.5 and it works there, but not on a clean x64 Windows machine that has never downloaded the old plugin… any thoughts?

  11. Hello William,

    I generated URL for the VM. On trying to connect to the VM using the URL(on both Firefox and IE) it is getting redirected to vSphere Web Client. Could you please help me to login to VM console. Also, I have installed client intergation tool (vmware-vmrc-win32-x86.exe)

    Thanks

    • You could either run it like a CGI script, some modifications would definitely be needed or frontend the script with a custom UI. Definitely possible

    • Hi William,

      can you please help me with this script? I am working on it for 2 weeks now, but I am not so good in perl and I don´t get it working. Thanks in advance.

  12. Hi William. Do you you know if it’s possible to generate a URL for the summaryView of a VM, without showing the vCenter/environnment navigation pane on the left?
    Thanks

  13. Hi William,

    Thanks for the script! Looks like vmware changed the order in the URL again for 5.1, so I modified your script and below seems to work:

    (…)
    if($vcVersion eq “5.1.0”) {
    my $vcInstanceUUID = Vim::get_service_content()->about->instanceUuid;
    my $vmMoRef = $vm_view->{‘mo_ref’}->{‘value’};
    $remoteURL = “https://$vc_name:9443/vsphere-client/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:$vmMoRef:$vcInstanceUUID”;
    }
    elsif($vcVersion eq “5.0.0”) {
    (…)

    Great news with PowerCLI 5.5 though (http://blogs.vmware.com/vipowershell/2013/09/powercli-5-5-whats-newoverview.html), looks like this will be builtin in PowerCLI:
    “Open a console for vSphere/vCloud VM
    Open multiple consoles at once
    Output the URL to open VM Consoles”

  14. Hi Wiiliam,
    I just like to know if we can open VM console from the Vcenter Server accessed with external link. I get an error ” Remote Console connecting which finally results in a time out” . I have the vcenter server installed offsite and I access it with IE10 win7 browser, I can open Vcenter Server, can do most of the management tasks but I can not open the Console of the virtual machine. You help will be greatly appreciated. I searched the net but nothing worked so far.

  15. Hi William, I have recently build my VSphere 5.5 home lab and have used port forwarding in my ADSL Router to connect to the same from my work place. I am able to access my VCenter server but I am unable to access the console of any virtual machine via web browser. I have tried to port forward the ports 902 and 903 for both ESX Host IP and VCenter IP but it has not help. Can you suggest a way that I can achieve this ??

    Please let me know in case you have any queries with respect to the above.

    Many Thanks,
    Rohit Narula

  16. Hey William,

    First, I’d like to thank you for your hard work, we’re using many of your scripts in XtremIO and it has really increased our efficiency!

    I’m trying to create an HTTP CGI form to open a console directly to the machine.

    I’m trying to use either generateVMRemoteConsoleURL.pl script and I get ‘null’ error.
    I also tried to use generateVMHTML5Console.pl but since it has 60 seconds sleep and then Util:disconnect(), the session is ended and I can’t pass it to my CGI form.
    I tried remove the Util:disconnect but apparently it doesn’t work.

    We’re running vCenter 5.5.0 build 1750787.

    If you have any advise it’d be awesome!

    Thank you so much!

    • Hi Eran,

      Great to hear these scripts have been useful for XtremIO, always great to hear feedback 🙂

      For your questions:

      1) How are you running the script? Sounds like you may not be passing in the right param
      2) The 60sec timer is just an example, you can always tweak the script. Removing the disconnect is not what you want, else you’ll leave stale sessions. The idea here is that you need to persist the API connection prior to running the HTML5 URL, else the session will not be valid.

      • Hey,

        Thanks for the quick response!

        For the first script:
        I’m running generateVMRemoteConsoleURL with the following params:
        ./generateVMRemoteConsoleURL.pl –server example.org –vmname vm1 –username eran –password xxx

        I’m getting the following link:
        https://example.org:9443/vsphere-client/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:vm-34299:F7355912-7E10-457F-A855-164B7284C3F7

        I copy/paste it to the browser and it says: ‘null’.

        I left generateVMRemoteConsole and tried to use VMHTML5Console instead:
        So basically I created a web HTML form that passes the variables to the generateVMHTML5Console.pl file and then it redirects the generated URL to the browser.
        Everything looks fine but since it has Util:disconnect, the URL is no longer valid.
        I’m not sure how you’d use it in a HTML form if it has disconnect in it. I don’t really understand how to make a connection prior to the URL generate, and then disconnect it..

        I hope you can assist!

        Thanks once again!

        • Hi, Thanks a lot. I like the script and finally was able to make it work after installing a VCli etc. on a VM.

          I am also fighting with the “null” error. I am running on the same version as Eran.

          Not sure if that helps to find a solution: The link works if you paste it into another tab of a browser in which you are already logged into the vcenter WebClient. But obviously that is what I want to avoid to simplify things for the users. Note that my users are local vcenter users and not Active directory users.

          Does it have to do with the authentication? How should it look like in the first place when you paste the link into an unauthenticated browser tab? Would we get the vcenter user password prompt?

          Kindly advise how we could solve this issue.

          Thanks

          • @Bei, were you able to sort it out? Looking at the developer console in Chrome, it seems that the cookie is never changed unless I connect to the vcenter web in another tab.

  17. @Bei, were you able to sort it out? Looking at the developer console in Chrome, it seems that the cookie is never changed unless I connect to the vcenter web in another tab.

  18. Hey @rv, Bei,

    I just wanna mention that I faced the same issue before and the workaround I used is just after generating the URL I open another connection to the database, for example: Util::connect($vm_serverUrl, $username, $password);
    Then, a command after it I just close the session: Util::disconnect();
    I also removed the 60 seconds wait because I wanted it to be a CGI web page.
    I had no issues so far. Haven’t seen any stale connections to the database.

  19. @n0rus,

    Sure, I hope it’s OK with W.Lam 🙂

    I just want to let you know that I’m newbie to Perl so the script might look bad.
    In any case, it works pretty well for me.

    Bascially, the script is not only generating a console web page, but it also allows you to power on, off and reboot a VM from a HTML form I created.
    If you need also my HTML form or some explanation on the code below, let me know.

    http://pastebin.com/prHnQAiN

    Eran

  20. Hi William,

    I just want to share a dedicated server with some friends. Is it possible to use the VM remote console without vCenter Server? vCenter Server has no free version and uses more ressources than any of our Guests (or dedicated Server has only 8GB ram…).

    Cheers-
    Simeon

  21. Hi all,

    I dont find the script on the given link. Could anyone direct me to coorect link from where i can download the script.

  22. I managed to get the script, I used comamnd the vCLI but I am getting error that script is not recognized. then i opened powersheel script editor open script via it then getting message as below :

    + ~
    An expression was expected after ‘(‘.

    At C:\generateVMRemoteConsoleURL.ps1:95 char:28
    + $permission_string .= “&tabs=show_”;
    + ~~
    Unexpected token ‘.=’ in expression or statement.

    Not all parse errors were reported. Correct the reported errors and try again.

    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingExpression

    Pls suggest.

  23. Hi I managed to run the script and it is also generating an url. If I put this url in web browser it is giving error 404. Please suggest

      • Hi,

        vSphere version is 5.5 just upgraded from 5.1 . I am running script via vMA.

        If i not wrong just from one of your blog read to edit the generated url from http to https and port from 7331 to port 7343.

        But libk already has https and port is no where in generated link.

        Also tried both chrome and in IE.
        Pls suggest.

  24. Hi,

    vSphere version is 5.5 just upgraded from 5.1 . I am running script via vMA.

    If i not wrong just from one of your blog read to edit the generated url from http to https and port from 7331 to port 7343.

    But libk already has https and port is no where in generated link.

    Also tried both chrome and in IE.
    Pls suggest.

  25. @Eran: could you suggest steps for running the html form and your scripts. thanks in advance

  26. Hi,

    Thanks for the great work, I was trying this with vcenter 6, but there seems to be an issue with xml version. Have you tried this with v6?

    Cheers

  27. Hi william,

    Im getting a pop up message box saying “null” if i paste the url into the browser…is there any specific reason for this ?
    how can i resolve this ?

  28. Hi William,

    I running Vcenter Appliance 5.5 update 2b (build 2183111), i just used HTML5VMConsole script to generate link, it’s can be console success but have problem with mouse pointer, I can’t see mouse or moving it, but still can action (left & right click) on somewhere of screen (mouse location is not changed).
    Is there bug of vmware html5 console or problem cause my vmware version ? I tried many browser like Chrome,IE,FF but same result.
    Need advise and suggest from you.

    Thanks and best regards,

  29. Hey,

    I see this is no longer supported with vCenter 6:
    404 – Page not found

    The following page could not be found:

    /console/
    Please contact your network administrator for help.

    Any idea what’s the new redirect URL?

    Thanks!

  30. Oh, there ya go:
    You need to add /vsphere-client/weconsole.html?
    my $redirecturl = “https://” . $vcenter_fqdn . “:” . $htmlPort . “/vsphere-client” . “/webconsole.html?vmId=” . …..

  31. Hi All,

    I am trying to generate VM REMOTE CONSOLE URL for vCenter 6.0 to access the VM CONSOLE from web browser but I am not able to end up correctly.
    Can any one help on this.

    Thanks in advance.

    Thanks and Regards,
    Sathya Prabhu Ravi

  32. Hi,

    I have got a powershell script in order to open the console Remore of all VMs of my vCenter but I need to open in full screen mode. Someone managed to do?

    Thanks for your article. 5 stars

Thanks for the comment!