Linux optimize

How do I run a remote Linux desktop in Windows?

The ability to connect from Windows to Linux is all you need to make administrating from a central location much easier. Jack Wallen explains.

Recently I wrote an article "How Do I Connect to a Remote Windows 7 Desktop from a Linux Machine" and was asked to show how to do the same trick -- the other way around. You might assume this trick to be a challenge. You will be surprised how little of a challenge it really is.

But first off, you might be asking yourself "Why would I need this?" The answer is to use a single point of administration. How many times have you scurried around computers to try to resolve a problem only to have to waste time going back and forth. With the previous article, you were given the means to connect from Linux to Windows. Now, with the ability to connect from Windows to Linux, you have all you need to make administrating from a central location much easier. And with that said, let's get on with the setup.

This blog post is also available in PDF format in a free TechRepublic download.

Assumptions

First and foremost I am going to assume both Windows and Linux desktops are operating correctly and are on your local LAN. To make things simple, I will use the 192.168.1.x IP addressing. And, as you could assume, it's always easier (in this case) when the IP addresses are static (otherwise you will find yourself tracking down IP addresses of your desktop machines).

Software used

There are only two pieces of software necessary:

  • x11vnc: Installed on the Linux machine to use as the VNC server
  • TightVNC: Installed on the Windows machine to use as the VNC client

Installing the Windows software is straightforward for most users. Just download the installer and double-click. For many Windows users, the installation of the Linux software might not be as straightforward.

Of course, the Linux installation will depend on your distribution. But basically all you have to do is follow these steps:

  1. Open up your Add/Remove Software tool (such as Synaptic, Ubuntu Software Center, gnome-packagekit, etc).
  2. Search for "x11vnc" (no quotes).
  3. Select the results for installation.
  4. Click Apply to install.

Now, if you are more comfortable with the command line, you can install the Linux software like so:

  1. Open up a terminal window.
  2. Issue a command like sudo apt-get install x11vnc (this will depend on the distribution you use).

Once all the software is installed, you are ready to go.

The Linux side

This is really quite easy. All you have to do is start the x11vnc server. If you look at the manual page for x11vnc (issue the command man x11vnc), you will see numerous options available for the server. One of those options you might want to consider is the -forever option. If you don't add this option to the command, your x11vnc server will die as soon as the client quits the session.

So the command you will want to run, from the terminal, is:

x11vnc -forever

You will notice you do not get your prompt back. Even if you add the & character, x11vnc will not return you to your prompt. Because of this, you might want to consider adding a line like x11vnc -forever to the end of your /etc/rc.local file. This will ensure your x11vnc server is started at boot.

The Windows side

Now it's time to connect. You've already installed TightVNC on the Windows machine, so go to the Start menu and fire up TightVNC. When you open the tool, a small window will appear (Figure A) that allows you to enter an address for the connection as well as open the Options window.

Figure A

Make sure you select the Connection Profile that best matches your connection type.
In the Options window (Figure B), there are a number of items to configure. Unless you need a specific configuration, the default generally works pretty well.

Figure B

You will notice that you can set TightVNC in View mode, which effectively connects the client to a noninteractive session. This is always good for training purposes.
After you make all your configurations, click the Connect button, and the connection will be made (Figure C). The speed at which TightVNC runs will vary depending on the speed of your network. But you should find it to be a very workable solution.

Figure C

Select options and make the connection.

Final thoughts

And there you have it -- a simple way to make the connection between the Windows and the Linux desktops. Your administration world just got a bit easier.

Stay on top of the latest XP tips and tricks with TechRepublic's Windows XP newsletter, delivered every Thursday. Automatically sign up today!

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

57 comments
rajhanschinmay2
rajhanschinmay2

I am getting error on Windows machine when I am trying to login into Linux machine.Error says:

Error in TightVNC Viewer, a connection attempt failed because the connection party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I have done all the steps needed and stated above.
Can anyone help.

digitaltoast
digitaltoast

Was having BIG problems downloading a 1.7gb Facebook archive via my 1.5Mb/s broadband. Used this to fire up a remote Firefox session on my Ubuntu VPS, et viola! Total time including download - 15 minutes. Thanks!

vikrant.korde
vikrant.korde

It worked like passing a hot knife through butter (makkhan mein garam churi). Regards, Vikrant Korde

Bebe56
Bebe56

Xming, the best there is.... nice, clean, easy... and FREE (well, you might want to send a VERY well-deserved donation). I'm using it for SLES 11 from a WinXP box.... i don't know about other distros but works great with SuSE... http://www.straightrunning.com/XmingNotes/

brianvu
brianvu

Hi Thanks Jack for the post. This is exactly what I need to have. I had problem installing the package on my 32-bit Oracle Enterprise Linux with the configure command as following. Please advise. Thanks configure: error: ========================================================================== *** A working X window system build environment is required to build *** x11vnc. Make sure any required X development packages are installed. If they are installed in non-standard locations, one can use the --x-includes=DIR and --x-libraries=DIR configure options or set the CPPFLAGS and LDFLAGS environment variables to indicate where the X window system header files and libraries may be found. On 64+32 bit machines you may need to point to lib64 or lib32 directories to pick up the correct word size. If you want to build x11vnc without X support (e.g. for -rawfb use only or for native Mac OS X), specify the --without-x configure option. ==========================================================================

hkphooey
hkphooey

You might want to take a look at the UltraVNC client for windows as well. It has a couple of other additions, in particular file transfer and encryption of the connection which is essential when doing VNC over an insecure network. An alternative is to tunnel it through ssh.

ghouart
ghouart

TeamViewer is also good for helpdesk. Runs on win,macosx and linux

gpacba
gpacba

With Xming it?s too better than VNC. Export X11 is the best way to access Linux desktops. And in the other side Rdesktop is the best option. In both cases we don?t need any especial instalation in the remote system. All is native. Regards Gustavo

gpacba
gpacba

With Xming it?s too better than VNC. Export X11 is the best way to access Linux desktops. And in the other side Rdeskyop is the best option. In both cases we don?t need any especial instalation in the remote system. All is native. Regards Gustavo

dosida
dosida

x2go is even easier to setup and install. I did it in less than 20 mins and didn't need to setup anything except the port sshd is listening to. - uses same FreeNX libraries - easy configuration (just add your users in a special group on the server) - KDE,Gnome,LXDE,RDP,Custom Sessions and single applications supported - KDE Control Panel for easy user management. - DHCP & TFTP server for Thin Client deployment Give it a shot... I'm sure you'll like it.

Photogenic Memory
Photogenic Memory

Install freeNX on your linux box. Generate a remote key for security. Then install Nomachine client on Windows. SSH into Linux server and copy and paste key into Nomachine configuration and save. Finally click on Nomachine client application and supply username and password for linux user account. Voila! Instant desktop. It took me 30 minutes to configure it out my first time. I was clueless. LOL!

ireaneus
ireaneus

Has anyone found a solution like logmein or PCAnywhere to connect to a linux box that say is at a home office from outside like from another home office? This would be setting up remote support, like viewing their xsession.

russoisraeli
russoisraeli

Hello Jack, Why don't you give a thorough tutorial on X and SSH port forwarding with PuTTY? It's a more advanced topic where you can't use Add/Remove Software, but it could provide indispensable to more advanced users and those willing to learn. - Igor

david.walker2
david.walker2

I've been running a similar setup with for over 2-1/2 years with no problem. In fact, the entire development team runs like this, from WinXP desktops to SuSE Linux Enterprise Server. I wrote a user script for the Linux side to start an Xvnc session with the desired desktop window size and window manager (some prefer Gnome, some prefer KDE). The users simply have to run the script once in a great while after I reboot the Linux system. In fact, I most often have to remind them of that. I also wrote a script to kill any or all sessions running for a user, and remove lock files, prior to (or just after) one of these infrequent reboots. The upside of this is that the TightVNC window can be closed on the WinXP desktop, as during a reboot of the desktop system, and the session stays intact on the Linux system. When the connection is made again, everything pops back up right where the user left it. The VNC connections make it so much easier to deal with multiple machines spread across three locations on two floors. For those things requiring a command-line, I also use telnet sessions to the required systems. Of course, some things just can't be solved with anything besides a personal visit to the console, but every little bit helps.

DanLM
DanLM

I am running tightvnc as a server on FreeBSD where I vnc into it from my windows machine. Again, using Tightvnc. When reviewing the Tightvnc's web site, I noticed NO mention of Linux. But further googling to forums, I find Tightvnc being used as a server on Linux also. So again, my question. Why 2 applications. I use right now tightvnc on my FreeBSD box as the server and tightvnc on my windows machines. To be truthful, I am currently typing this post through the vnc. Tightvnc running both on the windows machine AND the Unix machine.

RAETO
RAETO

God but an overkill solution ;) Use the build in XP(your desktop screenshot show this) or the build in W7 client to connect xrdp. You have nothing to change on linux if u host KDE or gnome or X11. It's only to install the xrdp package. ;) I use this on ten linux desktop with mostly debian5 and jaunty, intrepid and a version before. Decrese the number of used programs ;)

nahman77
nahman77

Putty could be usefull for SSH access

Neon Samurai
Neon Samurai

From X to W and now from W to X. The only recommendation I'd add is to use Aptitude rather than Apt-get. Aptitude maintains a record of what packages where installed by request and what where dragged along as dependencies. When you aptitude remove or aptitude purge; it references the record and additionally removes any dependencies installed only to support the requested program. Apt-get is a wonderful package manager but lacks the record of what was installed in addition to the requested package. And my unanswered question; can this share an existing user session or will it create a session per connection. When I last looked at it, it seemed to keep separate from the local user. The idea would basically be to have an equivalent of Remote Desktop (session per connection) and Remote Assistance (shared existing session). This seems to provide the remote desktop which can be very handy; especially between platforms. Can VNC instead connect into an existing user's desktop to see there perspective (remote assistance)? I'll dig through the x11vpn config and see if it's simply a setting somewhere but thought I'd ask here encase someone beats me to the solution. Thanks again for the article though. This balances out the last one very nicely. Anything that removes limitations between platforms is a good thing.

Mark W. Kaelin
Mark W. Kaelin

How many different operating systems are on your network? How do you handle the administration?

ireaneus
ireaneus

I didn't see a download for Linux on their website http://www.teamviewer.com/index.aspx The sales pitch is great, if it does work for Linux I will definitely switch from logmein. Logmein is nice I like it alot but need something for Linux as well.

Grantmasterflash
Grantmasterflash

Just use Nomachine NX on both the server and client and you don't have to do anything. Just install and run. There is a two user limit on the free Nomachine NX server though.

Neon Samurai
Neon Samurai

I keep a portforwarded to my machine so I can connect with ssh. This gives me remote shell, remote GUI, remote copy, ftp, share mounting, adhoc proxy and port tunneling. That last one is the key if you're going into a Linux based machine at your home. Set a tunnel between local machine (ssh or putty) into your home machine (ssh) for local port 5900 to remote port 5900. Then, your VNC client connects to localhost:5900 which, do to the tunnel, forwards all traffic to home:5900. It remains inside the ssh encrypted tunnel so traffic is protected in addition to getting past your home router. Replace VNC and the port number with your applicable remote desktop program.

SysAdminII
SysAdminII

I know that pcAnywhere 12.5 does work with Linux and Windows both. I personally have never used it on a linux machine, but it does state on the box that it supports both operating systems.

Neon Samurai
Neon Samurai

But, you also mention X forwarding. How do the programs display under the local Windows desktop with putty X forwarding?

imsoscareed
imsoscareed

Another point is the more popular flavors of linux already have an RDP server installed, there is no need for the server software.

DanLM
DanLM

You can also get tightvnc for a thumb drive. http://www.tightvnc.com/portable/ TightVNC Portable Edition is a specially packaged distribution which makes TightVNC keep its configuration and connection history in the installation directory (typically, on a USB flash drive), instead of using the registry of the host computer.

DanLM
DanLM

The instructions are on the Tightvnc web site.

DomBenson
DomBenson

apt-get does track all packages installed, as well as the automatic/manual state (hence the message if you apt-get install a package already brought in as a dependency - "Package xxx set to manually installed"). It can also clear out 'old' dependencies through apt-get autoremove, and indeed alerts that they exist on install/upgrade. An alternative method for getting a desktop on a remote Linux machine is to run an NX server (like freenx), which is a full desktop through X over SSH. It's particularly useful for over-WAN access, thanks to the combination of effective compression and SSH encryption, but it is good locally too. NX clients exist for Windows, Linux and OSX. It also gives you a new session. You could achieve a remote assistance effect by putting a VNC (or similar) server startup in a login script. Then the server would be in the context of the user session.

pgit
pgit

The only out of the box complete windows config that handles ssh keys. Cygwin syntax is a bear to wade through if you're trying to backups with rsync over ssh, but CopSSH makes it as easy as it can possibly be. Still not "easy" by a long shot. I haven't experimented with NX yet, though I have recently begun Linux-to-Linux trials and it seems to work great. Problem is connectivity between the remote and local, for cross platform file access, again the point being primarily backups. For plain remote admin any number of tools work well, everything I see folks mentioning here (eg puTTY) The holy grail remains hands-off backups, meaning rsync over ssh.

yawningdogge
yawningdogge

I wish someone could iron the bugs out of this program. I had it working once on a slackware machine and it took about 2 weeks to accomplish. That machine crashed and I've not been able to repeat the effort. (Time constraints.) I also don't get why someone cannot get it to work without VNC and why it always appears to look for a connection at port 5610. It's a server with huge potential, but it's amazingly frustrating to work with.

lefty.crupps
lefty.crupps

Debian has 'xrdp' which is the X server/client over the MS 'remote desktop protocol'. I would imagine other distros have this as well. So, rather than requiring TightVNC (which is great, of course), you could use the Windows Remote Desktop app to access the GNU/Linux desktop, and use rdesktop on GNU/Linux to access the Windows desktop. Same (basic) technology for both directions, rather than different techs for each.

---TK---
---TK---

I'll put it like this... There is still a VAX machine running... There is a team for everything. lol, and I am only on one of the teams... How many team, god only knows...

jshaw4343
jshaw4343

XP and 3 flavors of Linux. Don't need to see a desktop, so terminal through Putty works for me. I even access my Debian file server from XP through a Putty connection.

rkuhn040172
rkuhn040172

Windows 2000 (for older version of AutoCAD), Windows XP and Windows Server 2003. KISS - Keep it simply stupid. Remote in using either Netmeeting (free, oldie but goodie) or CrossLoop (when they can't get a local IP address).

Neon Samurai
Neon Samurai

If I'm adminning a Windows Workstation, it's more pleasent to use a Windows machine. Being able to quickly mount the remote drive over CIFS is handy. While I've a Samba client under Debian which works great for mounting drives; it's less great for adhocl \\machine\c$ type connections from the run box. For remote desktop admin, it doesn't much matter though; both platforms have a client. Debian machines are admined by command line and usually from a Debian local machine. Putty/WinCP are good enough but nothing like working inside a *nix native environment. A few things have web interfaces like webmin depending on what they do so any browser works for that. osX gets the same treatment as above; usually an SSH connection and command line admin work. The few Apple workstations we have are used by fairly savvy folk though so there isn't a great deal of admin to do. Actually, Windows would be the odd one out. Unless it's windows, I'll usually use a Debian machine but nothing works with Windows like Windows does.

Neon Samurai
Neon Samurai

SSH gives me a whole lot of bang for my one publicly visible port but, if pcanywhere is not using encrypted traffic and solid authentication, one could simply forward that port from the router to the internal machine.

r_widell
r_widell

I don't know about the OP, but I've used the cygwin X display server to connect to my Debian (Lenny) box. http://x.cygwin.com/ I had to go this route after moving from Etch to Lenny and vncserver launched via inetd (with the -inetd option) quit serving up a display manager ([gkx]dm). I've only used this to start a new session, not for joining an existing session as launching vncserver from within an existing session still works for that.

DanLM
DanLM

For the first time, I have set up a desk top on my FreeBSD machine. I have only ever used it as a server before with ssh logins only. But, I know via the KDE desktop that I am using that there is remote desktop applications. Which brings up a question? I am currently(right now) tunneling tightvnc through putty(ssh2) to my home bsd machine from work. Internet, not lan. Would I be able to do that with a RDP server?? Oh well, shows how little I really know.

Neon Samurai
Neon Samurai

With ultraVNC, I had to go hunt down an AES plugin (the included encryption is lesser than AES). Is TightVNC providing tunneling these days? On a *nix it'd be easy to just ssh tunnel it but with Windows in the mix...

Neon Samurai
Neon Samurai

Not sure if it was Jack or Apoth that wrote it up.

Neon Samurai
Neon Samurai

Hm.. I hadn't actually thought of starting VNCd manually within the user session. In my particular case, the remote operator wouldn't be threatened by having to enter a command line either. hm.. must play with this on the weekend. If it's just opening a GUI app from my own session then SSH -X is the way to go. I admin'ed a Mandriva box easily with the draketools by X forwarding. Actually, I used to use a liveCD and notebook just to get a local X session and X forward my own apps from the computer in the other room for years. I should have a look at NX also though it's creating a new session duplicates existing options. Another option is never a bad thing though. With atp-get, I've used the autoclean option which is very nice. After some of the rpm cleanups I've done, seeing two or three packages listed with deborphan is fantastic. Does apt-get automatically remove packages at the time of requested package removal though? That may be the difference I'm wrongly remembering; aptitude blows away the orphans at time of removal rather than as a second step of going back to cleanup.

CFWhitman
CFWhitman

It does make sense to use the same technology for both Windows to Linux and Linux to Windows. Of course, there's no reason it couldn't be VNC as well.

Neon Samurai
Neon Samurai

I have to put some reading into the remote desktop protocol. Do you know how it's encrypted offhand? I'm told encryption can be added through group policy so I guess it's more a matter of if the xrdp deamon has a config setting. Also, will it share an existing user's desktop or does it create a separate login session when you connect into X? (need something that allowed demonstrations and observation)

pgit
pgit

Yeah,the whip marks across the back of the hands, stab wounds on the inner forearm... I got 'em too. Which is why I was able to appreciate CopSSH when I encountered it. It was recommended by someone in these forums a couple years back. It does set up on windows ready to use, fully functional including the ability to log in with keys. (and better; shut off password logins altogether) I can't recommend CopSSH enough. The only good I can say about cygwin is it's open source, so someone could come along and make it easy and usable. Trying to config cygwin is up there with VPN servers or SQL backends in the "according to the manual this should be working right now" department.

Neon Samurai
Neon Samurai

It was many years ago but the scars remind me that there is usually a better way. ;)

pgit
pgit

CopSSH brings on the needed cygwin modules and more importantly sets them up right the first time. Ever install cygwin directly? Getting it working with ssh keys is the closest thing to impossible I can think of in computerland.

Neon Samurai
Neon Samurai

That was going to be my guess but the name was escaping my memory. I really should give that another go but between VMs and having a Debian notebook booted 90% of the time, it'd be more for recreational interest.

Neon Samurai
Neon Samurai

As a client/server combination, it should be just as easy to point rdesktop at localhost:port as it is to use localhost:5900 with VNC. The only variable I can see is if you can specify a port for the client to use or have to drop your tunnel over the default port. (potentially not having rdp on the local machine to conflict with the tunnel)

Neon Samurai
Neon Samurai

My SSH doesn't accept arbitrary connections either and it's rare that I go in through password. Bruteforce is also very obvious based on testing (common referred to is fun with my home network). Actually, proxy tunneling has been fantastic for work too as I can test our external systems from a remote IP. I thought VNC was doing tunneling on it's own or you where using it under it's own encryption plugin. Between the debian notebook with me and X forwarding or terminal apps, it's been years since I've had need of VNC into a *nix box. Actually, I'm more often using VNC on Windows which is why the AES plugin for UltraVNC and lack of ssh tunneling option.

DanLM
DanLM

The way I do this is to use my U3 putty client, and tunnel the portable Tightvnc through that. Thats why i actually mentioned that you could tunnel tighvnc. I use it to tunnel into home from work. I can't find the origional article/post/tutorial that I used to set this up. Sorry. But I have found a bunch of other articles. Please note that my home SSH is set up to only work with public/private keys. by me tunneling via ssh into my home for vnc, I am not really worried about security any more.

Neon Samurai
Neon Samurai

I don't personally have an issue with doing a regular deborphan hunt. For the few things that have gone flakey though, aptitude just stuffs the the dependencies back in along with the requested package and I'm all set.. or have been so far. Of course, if the dependency was also being used in your compiled code, you may need to go back and reinstall it as a requested package rather than insidental package. For me, the bigger difference is Remove versus Purge. If I'm unsure about the removal, I'll Remove so that changed config files remain in place should I need to take a step back. I'll Purge if I'm sure it's going away which also blows out all the related config files outside of user home directories. The other things I've noticed is when searching. Aptitude Search looks through package names. If I want to find something in package descriptions, it's Apt-cache Search.

DomBenson
DomBenson

I think you're right that aptitude proposes to remove them by default, and apt just tells you that they are probably not required. It's a personal thing, but I prefer apt's method, as I am more interested in what *must* be removed to satisfy my request - the cleanup can then wait a few days, so if something goes unexpectedly wrong, it is clearer what should be done to resolve it.