Skip to: Site menu | Main content


 

A guide to building a software KVM switch

* April 11th 2006 Update : Thanks to the reader Alex who provided the baseline, I’ve revised this post to include the exact AutoHotkey script to complete the full KVM illusion! Enjoy! *

This guide, or tutorial, explains how I’ve used VNC to simulate the effect of using a regular hardware KVM-Switch to control my Ubuntu Linux server PC with my Windows XP main desktop PC.
However, this can be applied to any two sets of operating systems.

An introduction to KVM switches a^?? If you know what they are you can skip this part:
A KVM (Keyboard, Video, Mouse) switch is normally a little simple device which enables you to work with a single set of Monitor/Keyboard/Mouse and more than a single computer.
This allows you to hide a couple of PC cases away and easily and comfortably control them all with a single set of desktop peripherals.

It so happens that I’ve had KVM switches in a couple of my previous workplaces, and it’s pretty cool a^?? A quick key-combo and you switch to a different PC.
I also always wanted to get my own KVM switch for my home a^?? For easily controlling my main Windows XP PC and my Ubuntu Linux server.

But I never allowed myself to actually spend money on thisa^?? Seemed kind of an overkill for home uses.
So I simply used VNC..

An introduction to VNC a^?? If you know what this is you can skip this part:
VNC is an application (Well, technically it’s a protocol, but I don’t want to waste typing on thisa^??) which enables you to see and control a remote graphical desktop of a networked PC. It’s as if you’re actually sitting on that very computer, and it can work with any OS.
The VNC server component should be installed on the PC to be controlled, and the VNC client component on the controller PC.

Anyhow, I simply used regular old VNC, like most other people, to control my Ubuntu Linux PC with my XP machine. But I always yearned for an actual hardware KVM switch a^??
For the simple pleasure of easily clicking a keyboard combo and switching desktops. KVM switches were simply that easy a^?? VNC was too slow to do this. Find the icon, enter the password, switch to full screen etca^?? Just too clumsy.

And then a^?? EUREKA!!!
A few days ago, it hit me, a few years late, but it hit me a^?? It can be done! A true software KVM switch can be created very easily.

Below are the steps which I took to have the same effect a hardware KVM switch will provide you.
In my case we’re talking about 2 machines on the same LAN. The server (controlled) machine is an Ubuntu Linux PC. The client (controlling) PC is Windows XP.
The same could work with any other OS with very little, if any, modifications:

1. Make sure the server (controlled) PC has a VNC server up and running. Explaining this in detail is not the purpose of this article. Tutorials can be found very easily by using Google.

2. Install a VNC client on the client PC. I’ve installed TightVNC. I’ve found it the best and simplest, by far, for this end. This component is also known as “vncviewer”.

3. Connect as you normally would to the server and initiate a VNC session.
Save the session details to a local .vnc file by using the Save Connection Info As.. option. This would let you name and place the .vnc file.

4. Make sure the password is saved so you don’t need to enter it every time (A security hole I admit, but not TOO big since it’s stored locally on my XP PC).
This option would be available to you automatically – Following the step above you would be prompted with the question:
Do you want to save the password in this file? a^?? Answer yes of course.

5. Now you have a .vnc file somewhere on your client (XP) machine, which a double-click immediately opens the remote desktop a^?? no questions asked.

6. The next step for me was to set the configuration to better graphical quality than the default ones. The default graphics are pretty bad due to the compression level. Since we’re on a local network this wasn’t an issue. I want to think I have a KVM here. So I chose the “Hextile” encoding a^?? I have no idea what that means but I found it t be both eye pleasing and fast. I chose a Custom Compression Level of 6, and a JPEG Compression of 6.
I left all the other settings on default levels.

7. The next stage is to make sure that the option of “Full screen” is chosen a^?? This is a must for the KVM illusion.
Also, make sure you are running Ubuntu (Or whatever you have on the second VNC server PC) at the same resolution your main, VNC client, PC is running.

And here was the tricky part. VNC kept warning me every time that I’m about to use Full Screen mode and that I can use Control-ESC to exit this modea^?? I see the point, but this warning message box was the last thing preventing me from having a software KVM switch!
After long searching I’ve found the solution:
You can disable the warning by creating a DWORD registry value named
HKEY_CURRENT_USER\Software\ORL\VNCviewer\Settings\SkipFullScreenPrompt and setting it to 1.

8. Finally, the nicest thing about a hardware KVM switch is that you use it by simply clicking a button or a key combo.
Well, this was the easiest part: Create a Start menu shortcut to the .vnc file we’ve created in step 3.
Righta^??click the shortcut and Properties a^?? Use the “Shortcut Key” property to assign any shortcut you like! (I’ve used Ctrl-Alt-Z)

VOILA!!! I’m using XP as I normally would. I need to access my Ubuntu a^?? I click Ctrl-Alt-Z and my entire screen/keyboard/mouse set is magically controlling my other PC a^?? The perfect illusion!
I’m enjoying this hack tremendously, this really, utterly, make a hardware KVM-switch useless and unnecessary.

ADVANCED TIP: If you really want to have the full effect of actually switching back and forth between the two machines by using the same key-combo, you can use a wonderful freeware I recommend: AutoHotkey. This utility is an awesome and powerful Windows scripting and shortcut-keys tool which allows you to easily do almost anything. This utility actually even deserves its own post reallya^??

*Update* The full script should be:

^!z::
IfWinExist LibVNCServer
{
IfWinActive LibVNCServer
{
WinClose
}
else
{
WinMaximize
WinActivate
}
return
}
else
{
Run "Full path to the .vnc session file you created"
return
}


38 Responses to “A guide to building a software KVM switch”

  1. Chris Griffin Says:

    Nice!

    This will be my weekend project. I actually had a KVM switch for my PC & Mac and it broke after 3 weeks.

    I didn’t like it anyway because it was a VGA switch. I need a DVI KVM switch but they are really pricey ($150 and up). Hopefully I can follow your instructions for my Mac/PC configuration. Hopefully this configuration will put out a sharp display unlike the VGA switch.

  2. Avi Says:

    I came up with this solution due to the same exact issue. Had I had the money to buy a DVI hardware switch, I wouldn’t break my head about hacking a solution.
    Necessity is the mother of invention huh..?

    I just wish you’ll enjoy this cool solution as much as I am. :-)

    (BTW: If you’re on s fast LAN and need really good graphics – Try using no compression at all)

  3. Ted Mielczarek Says:

    Of course, the alternative to this, if you have room for a second monitor, is to setup both machines with their displays side-by-side, and use synergy ( http://synergy2.sourceforge.net/ ) to share one keyboard and mouse between both computers. I’m currently booting my Windows box without a keyboard or mouse attached, and using synergy from my Linux box to control both machines. I like this much better than a KVM approach, since you get extra desktop space (as in pixels), even if it costs some more desktop space (as in physical desk top).

  4. Anon Says:

    yeah dude, it’s called Synergy.

    a few google searches could’ve saved you a lot of time.

  5. loquacious Says:

    Haven’t any of you dorks ever heard of Win2VNC? http://fredrik.hubbe.net/win2vnc.html

  6. Avi Says:

    What’s wrong with you people?! :-)
    As I’ve already explained above, both Synergy and Win2VNC require two screens…

  7. Blog » Blog Archive » links for 2006-04-01 Says:

    [...] build a software based KVM switch (tags: make kvm) [...]

  8. Donghai Ma » links for 2006-04-02 Says:

    [...] AviDardik.com A^? A guide to building a software KVM switch (tags: cool DIY hacks linux network tips tools software utilities reference) [...]

  9. Jason Says:

    OK, so I see how easy it is to pull up PC #2 as a full screen VNC session. But it’s quite a pain to get out of that and back to PC #1.

    Got any shortcuts to close the tightVNC window?

  10. matthew dunn - blog » Blog Archive » links for 2006-04-01 Says:

    [...] AviDardik.com A^? A guide to building a software KVM switch [...]

  11. Web 2.0 Watch » Blog Archive » SOFTWARE KVM (HowTo) Says:

    [...] Check out this guide on how to create a software KVM. I followed the steps as described on Friday and even used Hotkeys to setup a toggle between my 2 computers. The funny thing is, is that it works much better than I could have ever imagined (best to go in with a glass is half-full mentality when trying these things). This is a fantastic article that acctually works exceptionally well! [...]

  12. Alex Says:

    Here is the AutoHotkey script to switch between current screen and remote screen (in this example, “hippopo”), using F12:

    F12::
    IfWinExist hippopo
    {
    IfWinActive hippopo
    {
    WinMinimize
    }
    else
    {
    WinMaximize
    WinActivate
    }
    return
    }
    else
    {
    Run
    }
    return

  13. Alex Says:

    In the previous comment, please replace “Run” with “Run path_to_hippopo.vnc”

  14. Dave M. Says:

    There is just one little problem with your software solution to a KVM switch. It’s the reason I use my second monitor for the other machine right now.

    I play games. A lot of games. I use websites to help me play the games. Most of the games I play take over the whole screen on my main computer. If I want to look at a webpage, I have to switch out of that program to see the browser. With dual monitor support, if I want to do a search on the webpage, I have to switch out of the game to do it.

    So this page showed up while reading blogs and I thought: Wow, a solution that might just work.

    Well, sorry. Switching to VNC is just as bad as switching to Firefox. A shame really. So I am still stuck with two keyboards, mice, and monitors unless I want to spend the money for a real KVM that might not work. One machine has USB keyboard and mouse, and the other has the old plugs for keyboard and mouse.

    Your solution is good for most other needs, but gaming doesn’t really fit.

  15. Avi Says:

    Dear Alex,
    Thanks for the excellent help!
    I used your script as a baseline and did indeed reached a full solution – The full script will be immediately posted.

    Thanks!

  16. AviDardik.com » Cool script to compliment the software KVM solution Says:

    [...] The guide to building a software KVM switch I’ve written a couple of weeks ago has been a great success. It has been posted to a couple of huge sites (LifeHacker.com, Downloadsquad.com), made it to del.icio.us most popular, got posted on many smaller sites, and just generally generated a lot of traffic and visitors for AviDardik.com. [...]

  17. Der Informatik Student » Erstell dir deinen eigenen Software KVM-Switch Says:

    [...] Aber schaut selbst: Build your own software KVM switch [...]

  18. Brett Says:

    If you have a DVI monitor that also has a VGA port, you can hook both machines into the monitor, run synergy, and use the monitor’s analog/digital switch to go from one to the other. It’s not effortless, but it takes up a lot less space.

  19. Dave Says:

    Hey there, this works great, just wondering if anyone has figured out what to change in the script to run more than two systems. I’ve gotten it working to change to 3 different ones using the autohotkey program, but can’t get it to go back to my main system from the 3rd one, coming back from the second one works fine, any ideas.

    Dave

  20. DanT Says:

    VNC doesn’t seem to view other screens very well. e.g. a large tree on google groups doesn’t come out well. Radmin does it(and is cheap), but Radmin is windows only. I’ll have to wait for Radmin or VNC to improve their act. Kavoom is awesome – no hacks necessary, but windows only, and expensive (per pc!).

    AutoHotKey is windows only. What does one use in a linux GUI to get “proper switching”?

    To “Dave”. I don’t know what method you’re using to switch comps. what method are you using?
    But, those scripts already posted should work for any number of comps. Each script, launches for a particular comp.

  21. John Says:

    “this really, utterly, make[s] a hardware KVM-switch useless and unnecessary.”

    I use VNC, but I picked up a low-end KVM anyway, which came in handy for tweaking my secondary machine’s BIOS. (Try that with VNC.) The 2-port models start at ~$25 retail.

    KVMs have their own drawbacks (i.e., compatibility problems with some hardware), and they’re often unnecessary for home use, but “useless” is an overstatement even for models with few features.

  22. Dale Says:

    After a couple of setbacks….generally me not following the instructions…VNC works great. I’m using WIN XP Home on one pc and WIN Vista Beta on the second with success. Would have bought KaVoom but couldnt get to work with Vista & company didnt respond to email…plus more cost than this solution. Thanks

  23. Draco Says:

    For some reason when I first tried getting this setup I had one hell of a time. I just tried again yesterday and it worked perfectly within twenty minutes.

    The only issue I have is when I’m on the remote linux desktop if I try to drag and drop files in gnome, the VNC session hangs and I have to kill it and restart the VNC server. Other than that, it works like a charm (except for switching back to the local desktop, but alt-tab works just fine :) ).

  24. ThatchSpace » Software KVM Switches Says:

    [...] and this great article over at AviDardik.com called A guide to building a software KVM switch [...]

  25. Taurus Says:

    Hi!

    First at all sorry for my terrible English. :-)

    I use VNC as KVM replacement during few years, but your article is great! You take me new cool improvements to my own software KVM switch!

  26. Derrek Says:

    Anohter flavour: http://www.maxivista.com

    Includes Synergy functionality PLUS using a secondary PC screen as an additional screen for a primary PC.

  27. KVM switch » Blog Archive » Compaq PCI Card KVM Switch Says:

    [...] AviDardik.com ” Blog Archive ” A guide to building a software KVM switch But I always yearned for an actual hardware KVM switch a … Der Informatik Student ” Erstell dir deinen eigenen Software KVM-Switch Says: … [...]

  28. KVM switch » Blog Archive » AviDardik.com ” Blog Archive ” A guide to building a software KVM switch Says:

    [...] AviDardik.com ” Blog Archive ” A guide to building a software KVM switch But I always yearned for an actual hardware KVM switch a … Der Informatik Student ” Erstell dir deinen eigenen Software KVM-Switch Says: … [...]

  29. marie Says:

    i would like to create my own software but i have no idea where to start or what to do
    i would really appreciate your help or tips

  30. A guide to building a software KVM switch « agrotime Says:

    [...] Link to Story: /2006/03/28/a-guide-to-building-a-software-kvm-switch/ [...]

  31. Remote Control Your Computer Using Hardware or Software Says:

    [...] VNC is the software based alternative for a KVM switch. You can remotely control to a computer (s) and work on it as if you were there physically. VNC transmits the keyboard and mouse events from one computer to another over LAN or the Internet. There are many free utilities available that you can choose, I tried TightVNC it is very user friendly and an IQ of -1 should see you through, if not then read A guide to building a software KVM switch. [...]

  32. Joe Says:

    end

    Much Better script in my opinion, I made it hide instead of minimize to keep the desktop clean. You can change F12 to your desired hotkey and SERVERNAME to your, well, server name.

  33. Joe Says:

    Much Better script in my opinion, I made it hide instead of minimize to keep the desktop clean. You can change F12 to your desired hotkey and SERVERNAME to your, well, server name.
    F12::
    DetectHiddenWindows ON
    IfWinExist KITCHEN
    {
    IfWinNotActive
    {
    WinShow
    WinActivate
    return
    }
    WinHide
    WinActivate Program Manager
    return
    }
    else
    {
    Run C:\Windows\win2k.vnc
    }
    return

    Sorry, I didn’t realize html was allowed and the script got commented out.

  34. Just This » Virtual KVM Says:

    [...] things like “virtual kvm” and “software kvm”. One search brought me to /2006/03/28/a-guide-to-building-a-software-kvm-switch/. This was just what I wanted to do. I already knew about VNC for remotely viewing computer screens, [...]

  35. Mike Says:

    Great Script from Joe (post #33). Thanks to the author to.. This works great…

  36. hotmatrixx Says:

    Hey. I tried VNC for the first time the other day. Immediately clicked onto this idea you have had (I am kinda new). But I see some complex script and a registry tweak for stopping the full screen prompt. All i did was start VNCViewer and go to ‘options>globals and untick it. hope that helps?

  37. alex Says:

    Hi, just one question, how do i access BIOS with the vnc? sometimes my machine crashes and i use kvm for remote access, but if i need to set anything during boot, using this solution will not allow me to do that right?

  38. Imri Says:

    Hey,
    First heard about Virtual Kmv 2day.
    Installed the VNC.
    Every time i close the viewer window, the controlled
    computer address is change, so i can’t get back to it with the saved file.
    how can i fix this?
    for now i have to open the desktop view from the controlled computer and it’s not what i need.
    i want to fully control it from the client computer, with out any need of using the controlled comp keyboard.
    1ox,
    Imri

Leave a Reply