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
Ashley says
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)?
William says
@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
Sathya Prabhu Ravi says
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
William says
@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.
Ashley says
@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).
Mahesh Thawari says
@Ashley can you guide me how it can be achieve without authentication. I can manage Ajax call but could not find the way for authentication.
Prakash P says
@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
Jason Dinsdale says
William, do you know if there's an alternate URL syntax that allows the VM to be referenced by the VM name rather that the MOID?
Yours optimistically ... Jason
William says
@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.
m0ntassar says
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.
William says
@m0ntassar, You need to install vSphere SDK for Perl or vCLI, it'll handle all the dependencies for you.
Anand says
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
William says
@Anand,
As mentioned to @Ashley in Oct 26 reply, this is not possible today.
Anand says
@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 ?
William says
@Anand,
I'm not aware of any since it's separate service but you can always perform an HTTP query to https://[vc-hostname]:9443/vsphere-client and if it responds, then it's running the vSphere Web Client.
VMGuru1 says
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?
BryanMcC says
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
VMGuru1 says
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?
Neha.. says
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
Amien Melody says
Nice info...thanks.
Chris says
Hi William,
the script is working fine for me. Is there a posibillity to call this script from webbrowser and give the arguments like:
http://localhost/generateVMRemoteConsoleURL.pl?vmname=VM001&vc-server=vCenter... ?
Thank you!
William Lam says
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
Chris says
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.
Ken says
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
Anonymous says
https://xx.xx.xx.xx/ui/?view=aHR0cDovL2xvY2FsaG9zdDo4MC9zZGsmbW89VmlydHVhbE1hY2hpbmV8dm0tNDcmaW52ZW50b3J5
PW5vbmUmdGFicz1oaWRlXw==
When i run this pl scritp its generating this above type URL please help me i m not able view.
LittleNickey says
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"
William Lam says
Thanks I've updated the script to cover both 5.1 & 5.5
satish ahlawat says
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.
Rohit Narula - Lead Consultant says
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
Eran says
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!
William Lam says
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.
Eran says
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!
Bei says
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
n0rus says
@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.
rv says
@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.
Eran says
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.
n0rus says
Thanks Eran! Would you mind sharing your full script please?
Eran says
@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
Tony Lindström says
Is the form still available somewhere. Bumped in to this thread and it looks exactly what I am looking for, but am too lazy to build an own html form..
Eran says
Hey Tony,
Sure, you can use this form:
http://pastebin.com/Rvrm00gC
I'm also using pure CSS and my own CSS so it might not look as good as you want but the form will do just fine.
Let me know if you have any issues.
Simeon Preuß says
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
William Lam says
You can check out the Standalone VMRC http://www.virtuallyghetto.com/2014/10/standalone-vmrc-vm-remote-console-re-introduced-in-vsphere-5-5-update-2b.html or using something like VMware Workstation (http://www.virtuallyghetto.com/2013/11/how-cool-is-that-using-vmware.html) or VMware Fusion (http://www.virtuallyghetto.com/2014/07/vmware-fusion-tech-preview-2-can-now-connect-to-esxi-vcenter-server.html)
Piya says
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.
Piya says
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.
Piyanka Kamdar says
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
William Lam says
What version of vSphere are you running?
Piyanka says
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.
Piyanka says
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.
William Lam says
I recommend taking a look at this updated article which contains a newer version of the script http://www.virtuallyghetto.com/2013/09/how-to-generate-pre-authenticated-html5.html
Piyanka says
Thanks William .I tried this one. Now i dont get 404 error. That seems to be cleared. But now I get the message pop up saying null and then it keeps on buffereing and no prgress. pls suggest.
maddy says
HI Piyanka,,were u able to resolve the null pop up ?
Piyanka Kamdar says
Does anyone could suggest me how we could eliminate null pop up? Thanks in advance
Piyanka Kamdar says
@Eran: could you suggest steps for running the html form and your scripts. thanks in advance
mili says
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
maddy says
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 ?
Saviola says
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,
Eran says
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!
Eran says
Oh, there ya go:
You need to add /vsphere-client/weconsole.html?
my $redirecturl = "https://" . $vcenter_fqdn . ":" . $htmlPort . "/vsphere-client" . "/webconsole.html?vmId=" . .....
Sathya Prabhu Ravi says
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
Raju Kumar says
Hi,
it is going to ask login after hitting this url
https://reflex.primp-industries.com:9443/vsphere-client/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:vm-1506:EE26E7F6-591B-4256-BD7A-402E5AC9E0A8
Sergio says
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
Krishnaraj Barvathaya says
Hi,
Thank you for the script, I was able to generate the URL but when I copy the URL and open it in a browser I get "The console has been disconnected. Close this window and re-launch the console to reconnect." message. Is there anything I am doing wrong?
Thanks
Krishnaraj
Inquisitive says
Fairly old thread. Can https links be created for vSphere Client version 7.0.3? If so, how? Thanks in advance
William Lam says
the same manner as outlined in blog post. Please attempt and use it as learning opportunity
Inqusitive says
Thank you for the reply.
When I request /vsphere-client/ the response is
This vCenter Server is not currently registered with a vSphere Web Client. Please use vSphere Client Administration Tool (https://localhost:{port-number}/admin-app) on the machine running vSphere Web Client to register this vCenter Server.
My account doesn't have admin role to the Administration Tool. I guess I need to contact an admin to enable this? Which is what is confusing because when I initiate a login, I have to choose/click the vSphere Client button to reach a login form.