summaryrefslogtreecommitdiff
path: root/lbxinit
blob: 6c3080f0436c2ff37da83b1a7844b60fe4e1badf (plain)
  1. #!/bin/sh
  2. # Neat little script for easy use of lbxproxy with ssh.
  3. # Based on this: http://www.gelatinous.com/aaron/tips/lbxproxy
  4. # and adapted by Jonas Smedegaard <dr@jones.dk>
  5. # Changes from original script:
  6. # * Instead of another custom script "remote-frame", simply open a
  7. # terminal and quit lbxproxy on exit.
  8. # * Ssh compression and X forwarding is explicitly enabled.
  9. # * Path to lbxinit is not hardcoded - just place this script somewhere
  10. # in your path.
  11. # * Get rid of "l" and "r" options (more intuitively in my opinion).
  12. # The following is from the web page:
  13. # How do I get lbxproxy to work with xauth/ssh? I can't connect.
  14. #
  15. # I kept trying to get lbxproxy to work over ssh, or even just with
  16. # plain xauth. The only way I could make it work was with 'xhost +'.
  17. # Finally I found an article by a Ted Rathkopf that showed me a way to
  18. # make it work. If you are getting access control problems to your X
  19. # server, here's what you need to do.
  20. #
  21. # Instead of just extracting your cookie or attempting to use the ones
  22. # that ssh creates for you, you must get your real xauth key over to the
  23. # target and fudge it so that the display entry is adjusted for the
  24. # proxy (:63 by default).
  25. #
  26. # Example:
  27. #
  28. # On my DSL host, I use 'lbxinit r ' (r is for remote). This causes an
  29. # 'lbxinit l ' on the remote host -- (l is for local). Yeah, there are
  30. # easier ways to do this, but I wanted to have one script I could copy
  31. # around.
  32. #
  33. # [the script itself]
  34. #
  35. # Hey, what's remote-frame?
  36. #
  37. # You need to start some long-running X app in the local section or else
  38. # lbxproxy gets huffy and quits after the first client exits, even
  39. # though the man page says otherwise. So, I open up a frame of my emacs
  40. # on that host.
  41. #
  42. # I turned off compression with -nocomp because ssh does its own stream
  43. # compression. You might need to enable it with the -C argument to ssh.
  44. #
  45. # The last thing I did was make an 'lbx' shell alias that sets my
  46. # DISPLAY environment to :63.
  47. #
  48. # Last modified: 2000/11/17
  49. PATH=${PATH}:/usr/X11R6/bin
  50. SCREEN=63
  51. # Empty hostname indicates executed on target host
  52. if [ "x$1" = "x" -a $# -ge 3 -a $# -le 4 ]; then
  53. LHOST=$2
  54. COOKIE=$3
  55. PRG=$4
  56. [ "x$PRG" = "x" ] && PRG="/usr/bin/x-terminal-emulator"
  57. xauth add $LHOST:$SCREEN $COOKIE
  58. xauth add :$SCREEN $COOKIE
  59. lbxproxy :$SCREEN -nocomp -terminate -compstats > $HOME/.lbxproxy 2>&1 &
  60. export DISPLAY=":63"
  61. exec $PRG
  62. # $PRG
  63. elif [ $# -ge 1 -a $# -le 3 ]; then
  64. RHOST=$1
  65. RCOOKIE=`xauth list $DISPLAY | awk '{print $2 " " $3}'`
  66. SSHOPTS="-C -X"
  67. [ "x$3" != "x" ] && SSHOPTS="$SSHOPTS -l $3"
  68. # ssh -f $RHOST bin/lbxinit l $RHOST "'$RCOOKIE'"
  69. ssh $SSHOPTS -f $RHOST lbxinit "''" $RHOST "'$RCOOKIE'" "'$2'"
  70. else
  71. echo "Usage: lbxinit host [prg [uid]]"
  72. echo " (and internally: lbxinit '' host protocol cookie [prg])"
  73. echo
  74. echo "Example: lbxinit an.other.host 'xterm +aw' js"
  75. echo " (where 'js' is the login name on an.other.host)"
  76. exit 1
  77. fi