'Run As' under Linux and FreeBSD


run-as
#!/bin/sh

if test -z "$2" ; then
  echo Usage:  run-as username command [arglist]
  echo ""
  echo This will run the specified '('GUI')' command via ssh as that user
  echo If you do not want to be prompted for a password, set up the
  echo user to allow an ssh cert to authenticate '('man ssh-keygen')'
  echo ""
  echo If launched from panel, use run-as-GUI
  echo press enter key to exit
  pause
  exit
fi

xxx=`xhost | grep INET:localhost`
if test -z "$xxx" ; then
  echo adding localhost as authorized to connect to this X server
  xhost +localhost
fi

uuu="$1"
shift

ssh -f -l $uuu localhost "env DISPLAY=127.0.0.1:0.0 $@ &"
      



run-as-GUI
#!/bin/sh

# this invokes 'run-as' via mate-terminal.  YMMV but if you try to invoke run-as
# from a mate or gnome panel it will hang if ssh prompts for password.  to avoid
# hanging the UI, run mate-terminal or gnome-terminal or something that lets you
# control it properly so that it goes away after prompting and launching.

mate-terminal -x run-as $@