{"id":21,"date":"2015-05-02T15:10:52","date_gmt":"2015-05-02T21:10:52","guid":{"rendered":"http:\/\/peterod.azurewebsites.net\/?p=21"},"modified":"2015-05-02T15:10:52","modified_gmt":"2015-05-02T21:10:52","slug":"remote-desktop-to-your-linux-azure-virtual-machine","status":"publish","type":"post","link":"http:\/\/www.perktime.org\/index.php\/2015\/05\/02\/remote-desktop-to-your-linux-azure-virtual-machine\/","title":{"rendered":"Remote Desktop to your Linux Azure Virtual Machine"},"content":{"rendered":"<p>If you\u2019ve ever wished you could get a GUI experience with your Azure Linux VM\u2019s, here\u2019s how you can do it. While I\u2019m not suggesting you should do this for production VM\u2019s that are running server workloads, there are times when it could be useful to get a full GUI with Linux. If you are onboard, here\u2019s what you need to do.<br \/>\n<strong>Note: <\/strong>If you want you could just follow the steps for getting VNC installed and be done. However, being able to use an RDP client from any Windows machine without installing anything could be more convenient.<br \/>\nI used CentOS 7.1 from the Azure gallery but other RedHat based Linux distros will probably work (e.g. Oracle Linux)<br \/>\n1) Login to your Linux VM<br \/>\n2) Install the GNOME Desktop using this command:<br \/>\nsudo yum groupinstall &#8220;GNOME Desktop&#8221; &#8220;Graphical Administration Tools&#8221;.<br \/>\nThis will take several minutes<br \/>\n3) Install TigerVNC:<br \/>\nsudo yum install tigervnc-server xorg-x11-fonts-Type1<br \/>\n4) Copy the vncserver.service file:<br \/>\nsudo cp \/lib\/systemd\/system\/vncserver@.service <a><span style=\"color: #000000;\">\/etc\/systemd\/system\/vncserver@:1.service<\/span><\/a><br \/>\n5) Using something like vi, edit <a>\/etc\/systemd\/system\/vncserver@:1.service<\/a>. Look for the &lt;USER&gt; tags in the file and replace with your Linux username.<br \/>\n# Clean any existing files in \/tmp\/.X11-unix environment<br \/>\nExecStartPre=\/bin\/sh -c \u2018\/usr\/bin\/vncserver -kill %i &gt; \/dev\/null 2&gt;&amp;1 || :\u2019<br \/>\nExecStart=\/sbin\/runuser -l <strong>&lt;USER&gt;<\/strong> -c \u201c\/usr\/bin\/vncserver %i\u201d<br \/>\nPIDFile=\/home\/<strong>&lt;USER&gt;\/<\/strong>.vnc\/%H%i.pid<br \/>\nExecStop=\/bin\/sh -c \u2018\/usr\/bin\/vncserver -kill %i &gt; \/dev\/null 2&gt;&amp;1 || :'[Install]<br \/>\nWantedBy=multi-user.target<br \/>\n6) If you are running a firewall, you may need to open the ports we will need:<br \/>\nfirewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-port=5901\/tcp<br \/>\nfirewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-port=3389\/tcp<br \/>\nfirewall-cmd \u2013reload<br \/>\n7) Install XRDP using these commands:<br \/>\n<span style=\"color: #000000;\">sudo rpm -Uvh <\/span><a href=\"https:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/e\/epel-release-7-5.noarch.rpmsudo\"><span style=\"color: #000000;\">https:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/e\/epel-release-7-5.noarch.rpm<br \/>\nsudo<\/span><\/a><span style=\"color: #000000;\"> rpm -Uvh <\/span><a href=\"http:\/\/li.nux.ro\/download\/nux\/dextop\/el7\/x86_64\/nux-dextop-release-0-1.el7.nux.noarch.rpm\"><span style=\"color: #000000;\">http:\/\/li.nux.ro\/download\/nux\/dextop\/el7\/x86_64\/nux-dextop-release-0-1.el7.nux.noarch.rpm<\/span><\/a><br \/>\nsudo yum install xrdp<br \/>\nsudo chcon -t bin_t \/usr\/sbin\/xrdp*<br \/>\nsudo systemctl start xrdp.service<br \/>\nsudo systemctl enable xrdp.service<br \/>\nsudo systemctl start xrdp-sesman.service<br \/>\n8) Start VNCServer<br \/>\nvncserver<br \/>\nYou will get prompted to enter a VNC password<br \/>\n9) Verify that VNCSever and XRDP are running with netstat \u2013ant:<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/8228.image_4E8C37F6.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border: 0px currentcolor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/6012.image_thumb_50C8C0B2.png\" alt=\"image\" width=\"514\" height=\"333\" border=\"0\" \/><\/a><br \/>\n10) Next add the endpoints for RDP and VNC to your Linux VM. It\u2019s probably a good idea to use ACLs to restrict access from a particular remote subnet (see this: <a title=\"http:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/virtual-machines-set-up-endpoints\/\" href=\"http:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/virtual-machines-set-up-endpoints\/\">http:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/virtual-machines-set-up-endpoints\/<\/a>). Go to your Linux VM in the Azure Management Portal and click on EndPoints. Add an Endpoint for RDP and VNC on ports 3389 and 5901. I picked a random port for RDP (you could do the same for VNC):<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/7776.image_3B74BF38.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/2185.image_thumb_2FDF01F9.png\" alt=\"image\" width=\"494\" height=\"406\" border=\"0\" \/><\/a><br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/3187.image_042E37FD.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/3107.image_thumb_78987ABD.png\" alt=\"image\" width=\"501\" height=\"412\" border=\"0\" \/><\/a><br \/>\n11) At this point you can test connectivity using a VNC Viewer:<br \/>\n&nbsp;<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/0572.image_3F156AC6.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/6663.image_thumb_5A4DC3C7.png\" alt=\"image\" width=\"498\" height=\"331\" border=\"0\" \/><\/a><br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/8284.image_5C8A4C83.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/4024.image_thumb_1BEA90C5.png\" alt=\"image\" width=\"497\" height=\"318\" border=\"0\" \/><\/a><br \/>\n12) Next, try a Remote Desktop Connection:<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/7266.image_720A1C8F.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/2313.image_thumb_2D5D824E.png\" alt=\"image\" width=\"366\" height=\"422\" border=\"0\" \/><\/a><br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/8270.image_247080C0.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/0184.image_thumb_43B32793.png\" alt=\"image\" width=\"486\" height=\"283\" border=\"0\" \/><\/a><br \/>\nSuccess!<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/8585.image_381D6A54.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/01\/68\/09\/metablogapi\/6874.image_thumb_5762A1D8.png\" alt=\"image\" width=\"646\" height=\"395\" border=\"0\" \/><\/a><br \/>\n12) (optional) If you don\u2019t need VNC exposed externally, you can delete the Azure endpoint and just use RDP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you\u2019ve ever wished you could get a GUI experience with your Azure Linux VM\u2019s, here\u2019s how you can do it. While I\u2019m not suggesting you should do this for production VM\u2019s that are running server workloads, there are times when it could be useful to get a full GUI with Linux. If you are &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.perktime.org\/index.php\/2015\/05\/02\/remote-desktop-to-your-linux-azure-virtual-machine\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Remote Desktop to your Linux Azure Virtual Machine&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":0,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}