Ivor O’Connor

February 15, 2009

Synergy, sudo and visudo

Filed under: Uncategorized — ioconnor @ 7:09 pm

The synergy client on one computer randomly crashes. Finding the keyboard and restarting synergyc, even if only once a day, is very annoying. It’s gotten to the point where a script to monitor and restart the process is needed. First thought was using a to-here script like this:

sudo synergyc x.y.z.t <<- _EOF_
sudo-password
_EOF_

Possibly putting the sudo password in a script file is asking for trouble. A better method would be to put the command in sudoer file so the password is not needed. I decided I’d better write up my own notes on how to do this.
Here are the steps from https://help.ubuntu.com/community/Sudoers:

  1. Seems like their notes for this first step can be totally disregarded.
    1. Be sure to have your favorite editor installed.
      For example to get gvim do:

      sudo apt-get install vim-gnome

    2. Add to the end of file ~/.bashrc :

      [ $DISPLAY ] && \
      export VISUAL="gvim" || \
      export EDITOR="gvim"

    3. Type sudo -E visudo and add the env-keep line above the reset like so:

      Defaults env_keep = "EDITOR VISUAL"
      Defaults env_reset

  2. Now the real steps, edit

    sudo -E visudo

  3. Add the following line assuming a locate synergyc is at the location /usr/bin/synergyc in the section Cmnd alias section:

    # Cmnd alias specification
    Cmnd_Alias SYNERGY_CMDS = /usr/bin/synergyc

  4. Add the following line at the end of the file after the %admin ALL=(ALL) ALL

    %admin ALL=(ALL) ALL
    ALL=(ALL) NOPASSWD: SYNERGY_CMDS

Now instead of typing:

sudo synergyc x.y.z.t

just type:

synergyc x.y.z.t

Now I can proceed to write a more secure script to monitor and restart synergy.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: