LinuxQuestions.org
Have you heard the LinuxQuestions.org Podcast?
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Tags used in this thread
Popular LQ Tags , , , ,

Reply
 
Thread Tools
Old 02-20-2007, 12:31 AM   #16
miedward
Member
 
Registered: Feb 2007
Distribution: RHEL 4, SOLARIS 10
Posts: 86
Thanked: 0

[Log in to get rid of this advertisement]
Interesting, this is yet another subtle difference between how things are handled on Solaris and Linux servers (at least the ones I work with). When I ssh into to a Solaris server, I always need the .Xauthority information from the original user or I get the MAGIC COOKIE error the original poster mentioned.

That explains why all the references to this issue were for Solaris, which I thought was unusual, but didn't look into carefully.

All my Linux servers have heads, so I don't fiddle around with them over ssh quite as often. Always good to learn where the differences are.
miedward is offline     Reply With Quote
Old 02-20-2007, 09:53 AM   #17
jlightner
Senior Member
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 3,551
Thanked: 147
Maybe I need to check it out on my HP-UX boxes. My verification was done on Linux.
jlightner is offline     Reply With Quote
Old 02-21-2007, 02:29 PM   #18
jlightner
Senior Member
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 3,551
Thanked: 147
Amazing - just a few minutes ago a DBA called about exactly this issue on an HP-UX box. However she was trying to "su - appuser" after logging in as root. (The opposite of what the original poster was doing.)

Using the information about .Xauthority I found the following worked:

Login as root
echo $DISPLAY
cp -p .Xauthority ~appuser ;chown appuser ~appuser/.Xauthority
su – appuser
export DISPLAY=<value from the echo above>
xterm

The xterm opened on the tunel I'd opened as root.

Of course I did NOT tell the user this because I'd have to get her to remember to clean up .Xauthority for appuser when done to insure no hole was left there. I told the user to ssh in as appuser so that the tunnel created was for appuser rather than for root.

I didn't try vice-versa (appuser su - to root) to see if it required this as well.

Last edited by jlightner; 02-21-2007 at 02:42 PM..
jlightner is offline     Reply With Quote
Old 09-17-2009, 03:15 PM   #19
donax
LQ Newbie
 
Registered: Jun 2008
Location: Vejby, Denmark.
Posts: 2
Blog Entries: 2
Thanked: 0
Quote:
Originally Posted by miedward View Post

When you open an X forwarding connection (or any X connection) information about that session is put in $HOME/.Xauthority which should only be readable by that user and root. Really, you should check and make sure (more about this again later), because if anyone else can read this file, they can hijack your X connection and do all sorts of exciting things like keystroke logging et cetera because all X11 information is sent unencrypted.

So, what you can do (besides just using "su" which preserves the prior users environment, so avoids the problem) is something like the following...

#echo $DISPLAY
localhost:10.0
#su -
#cp /home/username/.Xauthority .
#chmod 600 .Xauthority
#DISPLAY=localhost:10.0
#export DISPLAY
#xterm

This should give you your xterminal on the original client display. There are lots of ways to do this, some probably more secure (and certainly many more elegant) than this, but as long as you REMEMBER TO CHMOD THE COPIED .Xauthority FILE this should be as secure as anything else, I think. Probably should delete it after you are done, just for fun.
This works fine for me. Sudo is necessary when you have access to sudo but do not have the root password.

I think more people might be running as root and then it is not a good idea to "cp /home/username/.Xauthority /root/"

Either do "cat /home/username/.Xauthority >> /root/.Xauthority"
or more correctly do:

su - donax -c " xauth list " > X11auth
xauth add $(<X11auth)

You may avoid this by changing /etc/sudoers so that it does not
change the home directory, or you can manually set
set -a
HOME=/home/username/


And by the way the xhost command is there to test if the DISPLAY
variable and authorization cookies work. Xterm is good, for sure,
but is not always present on e.g. Debian installations, like
xhost is not always available. In order to install basic X11
clients (programs) on Debian, use

aptitude install xbase-clients

:-)
linux donax is offline  
Tag This Post , ,
Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo: broken pipe TiMiN8R Mandriva 3 09-17-2009 03:31 PM
Sudo: broken pipe codered54 Mandriva 1 10-06-2006 02:41 AM
sudo + x11 kurrupt Linux - Software 3 05-15-2006 09:43 AM
Sudo and ssh X11 fowarding Mike_the_Man Linux - General 1 05-04-2006 12:04 AM
Sudo and X11 programs 65_289 Linux - Software 1 05-17-2005 09:42 PM


All times are GMT -5. The time now is 12:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration