TeamViewer: Unattended auto-start in Ubuntu

Aug 4, 2011
Tested on: Ubuntu 11.04 (Natty Narwhal)

This is log of the steps to setup TeamViewer on Ubuntu on my laptop, so that I can access my laptop from any other computer, without any user interaction on my laptop's end. More importantly, TeamViewer should be started on each reboot automatically & should not interfere with user normal task(s).

Precisely its an effort to mimic TeamViewer on windows, where it can be used to remotely access the computer even before login to windows (Though this workaround is cheating as we use auto-login feature of Ubuntu. Read step 3 for details). Following are the main steps:
  1. Install & setup TeamViewer for auto-start - Detailed steps are here.
    • Download & install appropriate .deb file.
    • Add a new application in Menu -> System -> Preferences -> Startup Applications.
  2. (Optional) Some configuration to make sure that TeamViewer does not pop-up on user logins.
  3. Configure Ubuntu to automatically login & then lock the screen
Details of last two steps are given below.
Step 2:
This is optional step. Its safe to skip this step. If TeamViewer is added to auto-start on each login, the user gets the TeamViewer window on each login. This might be annoying after some time. So, the idea here is to use another application, devilspie, to hide TeamViewer window: put the TeamViewer window on another workspace and/or minimize it. Here is a very good devilspie tutorial.
  • Install devilspie (& maybe gDevilspie, a nice front-end)
  • Create devilspie directory mkdir ~/.devilspie
  • Create a file with name 'teamviwer.ds' & put following in it. ; generated_rule teamviewer ( if ( begin ( is ( application_name ) "TeamViewer" ) ( is ( window_name ) "TeamViewer" ) ) ( begin ( set_workspace 2 ) ( minimize ) ( println "match" ) ) ) It will put the windows with name "TeamViewer" on workspace 2 & minimize it. Make sure devilspie demon is running. Check gDevilspie GUI.

This is not a very elegant solution. There were some minor issues with the rendering of the TeamViewer window (Though it works without any flaw). There can be some other ways to put it in system tray using some application like alltray. But this workaround is good enough for me.

Step 3: Configure Ubuntu to automatically login & then lock the screen
TeamViewer will auto-start only when user is logged in. So in order to make sure that TeamViewer is started even in case of remote reboot, auto-login has to be enabled. But this is also a security/privacy threat. One of the easiest way to maintain security is to somehow lock the screen immediately after login in. We can create a custom xsession for the same. See note 2 below, if you are using some secured wireless network on Ubuntu.

Create a file /usr/share/xsessions/autolock.desktop with following content. Change username to the correct user name. [Desktop Entry] Name=Auto Lock Gnome Comment=Custom ~/.xsession script Exec=/home/<username>/.xsession X-Ubuntu-Gettext-Domain=gdm
Create another file ~/.xsession with following content: #! /bin/bash gnome-screensaver gnome-screensaver-command --lock gnome-session --session=2d-gnome Note the last line. I am loading the Ubuntu (Wihout any effects). You may want to change it to appropriate session. Check other .desktop files in /usr/share/xsessions/ for the correct command.

Now enable auto-login. Menu-> System -> Administration -> Login Screen. Select "Auto Lock Gnome" in the default session. Reboot & you should see the change. Check note 1 & 3 as well.

  1. You may opt to allow only selected computers to connect to the TeamViewer for better security. See 10.2 "Security Category" in TeamViewer manual
  2. If auto-login is enabled, Gnome-Keyring kicks in each time after auto-login & usually affects all application related to saved passwords including network-manager. This is especially important if you are using a secured network, like WEP etc, as the internet connection won't be active till user enters the password in Gnome-Keyring manually. Here is a very easy work-around to get internet connection without Keyring kicking in. You should apply this changes for only the trusted network(s).
  3. Please note that enabling Auto-login & configuring it to connect to wireless network automatically is a potential security threat. Try it at your own risk.