Not Equal C && !=C && 不等于西
RSS icon Email icon Home icon
  • SSH + X11 display after su to another user

    Posted on January 26th, 2010 Sean Add comments

         Sometimes we need to run the X11 application window via SSH. For example, I am user “A”, and SSH to host “example”. To be possible running X11 application window, we need to type the command:

    #ssh -Y A@example

         In addition to the SSH restriction, we need to run an X application as someone other than yourself. For example, the Virtualbox can be only run by user “B”. If the user “A” can sudo to become user “B” or “A” is the root, in order to allow user “B” access to user “A”’s display, B needs to import “A”’s .Xauthority cookie. We can use xauth to accomplish this and it’s a quick one-liner before sudo su - B:

         A@example:~#xauth extract – :`echo $DISPLAY |awk -F: ‘{print $2}’` | sudo su – B -c “/usr/bin/xauth merge -”
         A@example:~#sudo su – B
         B@example:~#VirtualBox &

    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

    Leave a Reply

    Be the First to Comment!