Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I'm trying to run gparted on my Raspberry Pi. After logging in with ssh -X pi@pi and trying to run sudo gparted, I get the error message...

X11 connection rejected because of wrong authentication.

When I try xauth list, nothing is shown, meaning that the xauth file is missing. What is the easiest way of getting the X11 forwarding to work?


Edit: I tried the suggestion from below, but the first step already fails:

root@raspberrypi:~# xauth list $DISPLAY

xauth: file /root/.Xauthority does not exist

How do I generate this file?

share|improve this question
1  
Is there actually an X session to forward the remote session to? You're not doing this in putty are you?! –  Jivings Aug 26 '12 at 21:03
add comment

3 Answers

A convenient way is to use the gksudo command instead. (From the debian package "gksu").

share|improve this answer
    
Yeah, this is probably a better, easier solution. –  Jivings Aug 26 '12 at 10:44
add comment

The problem is that the X session for the superuser doesn't know what the cookie is.

After logging into the Pi execute the following:

$ xauth list $DISPLAY 

This prints the cookie, something like this:

pi:10 mit-magic-cookie-1 4d22408aga55sad1ccd165723g77923ae

Then switch the superuser with su and set the cookie:

# xauth add pi:10 mit-magic-cookie-1 4d22408aga55sad1ccd165723g77923ae 

X-forwarding should now work for root.

share|improve this answer
    
Is there an arguement you can pass to sudo? –  Alex Chamberlain Aug 25 '12 at 21:33
    
@AlexChamberlain Not that I know of. –  Jivings Aug 26 '12 at 10:43
    
This doesn't work, unfortunately. See my edit in the original post. –  biologue Aug 26 '12 at 16:46
    
@zenbomb It appears you ran xauth list as root, which of course fails. You want to list the cookies for the user and add them for root. –  XTL Aug 27 '12 at 6:41
add comment

So I had the same error:

xauth: file /root/.Xauthority does not exist

when trying to add the cookie to the root account using (example only)

xauth add pi:10 mit-magic-cookie-1 4d22408aga55sad1ccd165723g77923ae 

I solved this problem by creating the /root.Xauthority file (logged in as root):

touch /root/.Xauthority

The command touch creates an empty file. I hope this helps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.