Securely remote control your Ubuntu via putty from a windows host (VNC+SSH)

Last time I had the following situation: I wanted to remote connect to my workstation from another workstation like in the following image:
SSH Linux Tunnel via Putty
My current workstation is the left one (I will call it “workstation“) and I want to connect to the computer on the right (”server“). The workstation is running Windows XP, the server is running on Ubuntu Feisty.

  1. Setup Server(SSH+VNC): You have to install SSH and activate the VNC-Server, to be able to securely connect to your server.
    1. Install SSH: Just install the SSH server by entering the following in bash:
      sudo apt-get install ssh
    2. Screenshot Remote Desktop Preferences Screenshot Remote Desktop MenuEnable VNC: VNC is already installed on yor Ubuntu system, so you only have to enable it. Navigate to System -> Preferences -> Remote Desktop. Now you should activate “Allow other users to view my desktop“, “Allow other users to control my desktop“, and for security purpose “Require the user to enter this password” and provide a secure password. Then click the Close-button. Now your VNC-server should be ready to use.
  2. Setup Rooter (SSH Forwarding). If your server is directly connected to the internet (modem) you can skip this step. On my SMC-router this feature is called virtual server. You have to forward the SSH-port (22) to the IP address of your server. (here: 192.168.123.2)
  3. Download and Install Putty: If you search Google for putty, the first result will be a download page, where you should download eighter the windows installer (putty-0.60-installer.exe) or the single putty program (putty.exe) . (I placed the single file into %windir%\system32 for fast access per Start -> Run.)
  4. Start Putty and set it up:
    1. Start putty.exe (e.g. if you put it in system32 per Start -> Run putty.exe
    2. Putty Step1Enter the hostname, you want to connect to on the first startpage “Session“. Here this is the router. You have to enter the external IP (in concreto: 80.80.205.145). If your “server” is directly connected to the internet you have to enter the external IP of your server. (This is the case if you have only a single PC and this PC is directly connected to the modem of your provider.
    3. Putty Step2Setup a tunnel by going to “Connection -> SSH -> Tunnels“. Here you enter as source port 5900 (the default VNC-Port which is used by Ubuntu if you installed it like me). As Destination you enter the internal server-ip with the VNC-Port (in concreto: 192.168.123.2:5900) and Click Add. Make sur, that you use the internal IP of your server not e.g. an IP-Adress of your router. (I made this mistake and wondered why nothing happend ;-) )
    4. Putty Step3Save your session and connect, so you can recall it later quickly by going back to “Session”. Type a meaningful name for your session below the “Saved Session” label and click “Save“. Now you can restore your session always by selecting it and click “Load“. Now you can click “Open” to connect to your server.
  5. Connect to your workstation: Now you will get a window where your username and password will be asked. Enter you login credentials to connect to your server and establish a SSH-tunnel.
  6. Connect to your server using VNC:
    1. Download and install VNC. There are lots of free VNC apps for windows out there e.g. UltraVNC or TightVNC. Note that you only need the viewer.
    2. Start the vncviewer and connect to localhost (127.0.0.1) and enter your password which you provided in step 1.2.
    3. Now you should be connected to your home server :)

34 Responses to “Securely remote control your Ubuntu via putty from a windows host (VNC+SSH)”


  1. 1 anarchore July 1, 2007 at 9:20 pm

    Hi, may I suggest a calendar widget so people can navigate to see your first posts?

    I am intrigued and wish to see your beginning.

    I am assuming you are describing the whole switch to Ubuntu, and start at the beginning?

    Please add the ‘calendar’ or better still ‘archives’ that can be searched by month.

    Take care;
    @

  2. 2 John July 2, 2007 at 3:56 pm

    Or, more simply, install hamachi on both the workstation and server, then (on the workstation) VNC to the server’s hamachi address (5.x.x.x). That way, encryption and port forwarding come for free.

  3. 3 star July 2, 2007 at 5:27 pm

    I use Hamachi with GHamachi on Ubuntu for a graphical interface.

  4. 4 ataub2qf July 2, 2007 at 5:36 pm

    @anarchore: calendar and archives added. I did not know this feature yet ;-)

    I was not blogging from the begin of my switch but I am blogging about some things I stumbled on.

  5. 5 Sofia July 2, 2007 at 5:56 pm
  6. 6 handband2 July 2, 2007 at 6:14 pm

    As John said, I like hamachi too. Instead of using VNC I prefere FreeNX. It seems to run so much faster. Here is some howto’s I use:

    Hamachi on Ubuntu
    http://forums.hamachi.cc/viewtopic.php?t=15075

    FreeNX
    https://help.ubuntu.com/community/FreeNX
    http://free.linux.hp.com/~brett/seveas/freenx/
    http://www.nomachine.com/download.php

  7. 7 Done July 2, 2007 at 10:03 pm

    I set up my “rooter” but my plumber objected.

    seriously, I would also link to the howto’s for securing SSH. The fact is that if you have port 22 hanging on the internet, go and check your auth.log, it’s kind of scary. I don’t think there are any default ubuntu service accounts that might allow shell, but certainly people need to disable root login in sshd.config and also I’d recommend putting denyhosts.py (is denyhosts in apt-get yet???)

    Cheers.

  8. 8 Ruff July 2, 2007 at 10:52 pm

    Um yeah. How do I run it if it’s on a dual boot and I am in windows and want to run ubuntu? I have access to the partitions on both OS’s

    That’s what I was hoping this article would be about.

  9. 9 Tom July 3, 2007 at 6:14 am

    I like NoMachine NX or freenx, secure and super fast + it lets you use more than one account at a time.

  10. 10 russ July 3, 2007 at 2:38 pm

    @Done
    You’re correct in saying there are no default ubuntu service accounts that allow shell, and as you may be aware, the root account in ubuntu is disabled by default (not only in SSH, but everywhere.)

  11. 11 psymon101 July 3, 2007 at 3:23 pm

    Great how-to… Ever tried Xming? Opens up a secure X session on a Windows machine using plink, excellent alternative.

  12. 12 DUDE July 4, 2007 at 1:10 am

    @RUFF:
    whoehahahahahahaha!!
    How on earth will you run Ubuntu AND Windows on one box (using the dualboot you describe)… What machine would you connect to from Windows? ehh… oops that instance in not running right? haha

  13. 13 Matt July 12, 2007 at 3:28 pm

    Doesn’t this arrangement assume that you remain logged into the “server” Ubuntu machine. If you log out, the VNC service is inactive, isn’t it?

    MMS

  14. 14 Doug July 24, 2007 at 3:34 pm

    @Matt I am facing this problem right now as I want to leave my Linux comp logged out and still access my VNC server and Azureus. If anyone has any tips that would be great!

  15. 15 ovizii September 24, 2007 at 5:28 pm

    I’d like to throw in some hints:

    you have to be aware, this discussion evolves around 2 different solutions: one is using a client software the other one “does not really need one”

    Have a look also here: http://ubuntuforums.org/showthread.php?t=541656 that post is about running a vnc - java server so you can connect via a browser.

    To make this safe I will describe my situation:

    being at work, almost all outside ports are blocked, so I have setup sshdaemon on my router @ home on port 443 which I am allowed to access from work. so if I connect via putty to port 443 and set up a dynamic tunnel, socks5 => only enter a local port, aka 88 and select dynamic. establish the connection to your router.
    then after you have set up your vnc - java server at home, and set your browser at work to use localhost:88 as proxy, you can simply connect to your home pcs internal IP on the port the vnc server is running. the browser using the dynamic tunnel, will forward your request to the itnernal network at home.

    => this achieves security, your home pc is not reachable from the internet, but only from your local net. :-) have fun

  16. 16 Mike January 29, 2008 at 1:12 pm

    Very helpful, thank you.

  17. 17 Anonymous February 4, 2008 at 6:36 pm

    xming

  18. 18 Huh March 9, 2008 at 11:36 pm

    These directions are a mess!

    If you overlook the typos –you are left with incomplete instructions.

    Where are the configuration instructions for the server?

    If you only establish one tunnel, (it’s called a cave! and it doesn’t work) You port-forwarded only one side. You have to configure the server to port-forward as well.

    Better instructions can be found here!

    http://www.mydemosite.org/Ubuntu-Remote-Desktop-Guide.pdf

  19. 19 George March 31, 2008 at 8:09 pm

    Thank you for instructions.

    These instructions worked fine for me, thanks a lot. I never knew Putty could do that. remarkable. Seems a little scary but seems a hell of a lot safer than riding vnc into my work network without encryption, which I have done. Still have a few questions like why can’t i access an ubuntu desktop via vnc unless i’m logged into the desktop first? Also, have questions about logging into windows remote desktop from an ubuntu machine. Does microsoft make a client/viewer available that will work? or is there an open-source client that will work? If you can answer these questions, great, if not, still i thank you for excellent and useful instructions which i personally have already made use of (with just a little prior knowledge of vnc and putty and router port-forwarding) and which i believe i would have been able to follow without my prior knowledge.

  1. 1 » Securely remote control your Ubuntu via putty from a windows host … Trackback on July 1, 2007 at 2:39 pm
  2. 2 bap booby » Blog Archive » How To: Control Ubuntu from Windows Trackback on July 2, 2007 at 3:17 pm
  3. 3 » How To: Control Ubuntu from Windows Trackback on July 2, 2007 at 3:22 pm
  4. 4 How To: Control Ubuntu from Windows at SoftSaurus Trackback on July 2, 2007 at 5:00 pm
  5. 5 Contrala de forma remota tu Ubuntu desde Windows : Trackback on July 2, 2007 at 5:31 pm
  6. 6 ¿Post largos o cortos? ¿hablar blogs o del iPhone? ¿gatos? « sitio en construcción Trackback on July 2, 2007 at 10:30 pm
  7. 7 Control Ubuntu from Windows at H4CKER.cc Trackback on July 2, 2007 at 10:57 pm
  8. 8 Top Posts « WordPress.com Trackback on July 3, 2007 at 12:58 am
  9. 9 links for 2007-07-02 « Random Musings Trackback on July 3, 2007 at 2:17 am
  10. 10 Knowledge Base » Archive du blog » Remote control ubuntu from windows Trackback on July 3, 2007 at 8:13 am
  11. 11 Italian Blogs » Blog Archive » Links for 2007-07-03 [del.icio.us] Trackback on July 4, 2007 at 7:08 am
  12. 12 Free as in Time » Blog Archive » "Remote Control" of an Ubuntu Box Trackback on July 11, 2007 at 3:02 pm
  13. 13 How To: Control Ubuntu from Windows Trackback on July 11, 2007 at 8:45 pm
  14. 14 Control Ubuntu from Windows at SoftSaurus Trackback on July 31, 2007 at 8:31 pm
  15. 15 links for 2008-01-27 « Romulo Lopez Cordero Trackback on January 27, 2008 at 7:18 am