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.

Notes:
  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.

Comments (12)

Loading... Logging you in...
  • Logged in as
This is such a good resource that you simply area unit providing and you provides it away without charge. I fancy seeing websites that perceive the worth of providing a chief resource without charge. i really loved reading your post.
Nice and interesting post. TeamViewer is now available for Mobile
Outstanding event. I simply love it. The ones guy's are without a doubt lucky.
BlackPrapor's avatar

BlackPrapor · 659 weeks ago

I did exactly what you say, and I'm getting this error message, when I manually login (autologin doesn't work for me either, there is just no scroll in the setting menu):
: unable to launch "/home/myusername/.xsession" X session ---
"/home/myusername/.xsession" not found; falling back to default session

Then I just get black screen and nothing happens, until I manually shut it down.
1 reply · active 659 weeks ago
Change to text login and make sure the file is present. Try Alt-F1 or Alt-F2 .. you should see a text login.
I think it was an issue of using Ubuntu 10.10, I upgraded to Xubuntu 11.10 and installed v.7 TeamViewer and gDevilspie works perfect now. No Ghost window either, reboot computer auto startup launches TV and Devil moves it to workspace 2 and minimizes, I'm going to remove the minimize command, I don't care if it's up on WS2.
Thanks for the post! I do have a problem hopefully someone else has already dealt with. I'm still runing Ubuntu 10.10 64bit, TeamViewer 64 bit as well. When I add it to my Startup Applications it does start the app, at least the window appears but I'm offline. I have to close it and open it from the Applications/Internet menu. I pointed the Startup Applications link to /usr/bin/teamviewer and /usr/bin/teamviewer6 on separate attempts but got the same result. I've also pointed the startup entry to /opt/teamviewer/teamviewer/6/bin/teamviewer which is what Applications/Internet shortcut points to.
Also, using gDevilspie I created the same rule you listed above, I don't mind the ghost window appearance but it does not move TeamViewer to workspace 2. Could this be an issue with 64 bit Ubuntu or because I'm still running 10.10? Thanks
1 reply · active 688 weeks ago
I do not know the exact solution to your problems. But I can suggest you few things :
- Make sure that your computer is online & is able to connect to Internet. Also check Note 2&3 in my post. It could be an issue.
- Try newer version of teamviewer V 7.0 Beta. It works great for me & it has more options many options which were disabled in v 6.0. Get the tar.gz file from the website (executable files, no installation required). And then try this one at startup.
- Frankly speaking I have stopped using gDevilspie or devilspie. It not required for the functionality. Unfortunately, I am no expert on it.
As you mentioned unattended in the title, was hoping to find the way to setup constant password as in other OS versions of TeamViewer... Any help there or in reading the session password via script? Auto-emailing myself the password on system reboot would be enough for my purposes.... Anyone can help?
3 replies · active 692 weeks ago
OK, I put together a workaround here: http://leonstafford.wordpress.com/2011/12/27/team... Thanks for the inspiration!
I read your article and I understood your problem. But you don't really have to access your desktop through session passwords. In fact I have totally disabled the "random" session password. Go to menu Extra -&gt; Options -&gt; Security tab. There you will find options to setup a password which won't change with sessions. There are also lots of others options like whitelist etc. This works with both version 6 & 7.

I highly recommend to disable teamviewer shutdown. You can find this option in Advanced tab. This will ensure that you dont loose access to your computer even if you clicked on the close button on teamviwer by mistake.
Lol! That'll teach me not to RTFM! I just assumed as they give you that as an option on install on Win/Mac that it was missing from the Linux one... I shall have to edit my post now ;) Thanks very much for pointing it out!

Post a new comment

Comments by