#!/bin/bash # Control GNOME remote access from the command line # By SukkoPera # Version 0.1 (22/02/2010) # # This script is a sort of text version of vino-preferences, which might be # useful to setup remote accesso to a GNOME desktop without having physical # access to the machine (i.e.: No monitor and no mouse). # # The supported functions are the following: # - Enable/Disable the server (automatically disabling the need to manually # accept incoming connections). # - Change the TCP port the server is listening on. # - Change the password needed to connect to the server. # # This script has been tested on GNOME SlackBuild 2.26 running on Slackware # GNU/Linux version 12.2. # # Contains material from the following links: # http://www.samlesher.com/ubuntu/ubuntu-704-enabledisable-remote-desktop-from-the-command-line # http://berrange.com/posts/2007/09/05/remotely-setting-up-remote-access-to-a-gnome-session/ # # Released in the public domain. # case "$1" in start) gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled true gconftool-2 -s -t bool /desktop/gnome/remote_access/prompt_enabled false echo "Remote Access Enabled" ;; stop) gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled false echo "Remote Access Disabled" ;; passwd) curpwd=$(gconftool-2 --get /desktop/gnome/remote_access/vnc_password) curpwd=$(echo $curpwd | base64 -d) echo "Current password is: $curpwd" echo -n "New Password (Max 8 chars, Enter to quit): " stty -echo read passwd1 echo if [ -n "$passwd1" ] then echo -n "Repeat: " read passwd2 echo stty echo if [ "$passwd1" == "$passwd2" ] then gconftool-2 --type list --list-type string --set /desktop/gnome/remote_access/authentication_methods '[vnc]' passwdb64=$(echo "$passwd1" | base64) gconftool-2 --type string --set /desktop/gnome/remote_access/vnc_password $passwdb64 if [ $? -eq 0 ] then echo "Password changed." exit 0 else echo "There was an error changing your password." exit 1 fi else echo "The entered passwords do not match. Password unchanged." fi fi stty echo ;; port) enabled=$(gconftool-2 --get /desktop/gnome/remote_access/use_alternative_port) if [ "$enabled" == "true" ] then curport=$(gconftool-2 --get /desktop/gnome/remote_access/alternative_port) else curport=5900 fi echo "The VNC port currently in use is $curport." echo -n "Enter the new port to be used (Or Enter to quit): " read port if [ -n "$port" ] then if [ $port -eq 5900 ] then gconftool-2 --type bool --set /desktop/gnome/remote_access/use_alternative_port false else gconftool-2 --type bool --set /desktop/gnome/remote_access/use_alternative_port true fi gconftool-2 --type int --set /desktop/gnome/remote_access/alternative_port $port echo "Port set to $port" fi ;; *) echo "Usage $0 start|stop|passwd|port" ;; esac