Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

start programs over X with ssh using sudo

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
Eazy
Posts: 31
Joined: 2009-07-01 20:19

start programs over X with ssh using sudo

#1 Post by Eazy »

Hi!
I have trouble starting X-programs with sudo and ssh. I get this if I try:

Code: Select all

$ sudo medit
X11 connection rejected because of wrong authentication.
Every time I log in I have to run as su:

Code: Select all

xauth add $(xauth -f ~username/.Xauthority list|tail -1)
if I want to run a X-program as sudo.

I can start programs as normal user OK, so my ssh is working.

I have the latest Debian without X installed.
I log in to my Debian with:

Code: Select all

ssh -X server@IP
I have tried with -Y but the same problem.

Can I set my command (]xauth add $(xauth -f ~username/.Xauthority list|tail -1)) permanent so I don't have to run it every time i log in?

This problem is new to me. It has always worked out of the box.

Eazy
Posts: 31
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

#2 Post by Eazy »

Really, no one?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: start programs over X with ssh using sudo

#3 Post by Head_on_a_Stick »

Have you tried pkexec?

I think gksu{,do} is discouraged these days because it allows too many permissions.

Anyway, this is an XY-problem: the correct answer is of course

Code: Select all

sudoedit $file
deadbang

Eazy
Posts: 31
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

#4 Post by Eazy »

wizard10000 wrote:You'd use gksudo or gksu, same as if you were on your local machine.
Thanx. I installed gksu and it does work.
Head_on_a_Stick wrote:Have you tried pkexec?

I think gksu{,do} is discouraged these days because it allows too many permissions.

Anyway, this is an XY-problem: the correct answer is of course

Code: Select all

sudoedit $file
I get this with pkexec:

Code: Select all

$ pkexec medit
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/bin/medit' as the super user
Authenticating as: root
Password: 
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized

This incident has been reported.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: start programs over X with ssh using sudo

#5 Post by Head_on_a_Stick »

^ You need to write a pkexec configuration file for medit then, use /usr/share/polkit-1/actions/com.ubuntu.pkexec.synaptic.policy as a guide, it's fairly simple ;)

That does seem to indicate that the medit developers don't want you running it as root though else they would have supplied such a file with the package.
deadbang

Eazy
Posts: 31
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

#6 Post by Eazy »

I also have a Ununtu server, but there I don't have any problem with using -X with sudo. I wonder how Ubuntu got it working? Well, it works now with my Debian server with gksu, but I'm curious about why it does not with Debian.

milomak
Posts: 2158
Joined: 2009-06-09 22:20
Been thanked: 1 time

Re: start programs over X with ssh using sudo

#7 Post by milomak »

Eazy wrote:I also have a Ununtu server, but there I don't have any problem with using -X with sudo. I wonder how Ubuntu got it working? Well, it works now with my Debian server with gksu, but I'm curious about why it does not with Debian.
yep ssh -X -l login_name server_ip_address works for me

when you are on that machine (the one giving the problem) physically, are you able to run X programs using sudo?
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: start programs over X with ssh using sudo

#8 Post by debiman »

Eazy wrote:

Code: Select all

xauth add $(xauth -f ~username/.Xauthority list|tail -1)
this command is wrong. i hope it's just a typo.
I have the latest Debian without X installed.
I log in to my Debian with:

Code: Select all

ssh -X server@IP
i also have debian without X on my server.
i cannot use ssh -X or -Y - unsurprisingly, because there's no X11 to forward!

i'm guessing that these both points are just mistakes in your narrative, since it clearly seems to be working for you (except for the authentication problems).

Eazy
Posts: 31
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

#9 Post by Eazy »

debiman wrote:
Eazy wrote:

Code: Select all

xauth add $(xauth -f ~username/.Xauthority list|tail -1)
this command is wrong. i hope it's just a typo.
I have the latest Debian without X installed.
I log in to my Debian with:

Code: Select all

ssh -X server@IP
i also have debian without X on my server.
i cannot use ssh -X or -Y - unsurprisingly, because there's no X11 to forward!

i'm guessing that these both points are just mistakes in your narrative, since it clearly seems to be working for you (except for the authentication problems).
The command is not wrong. You have substitute "username" with your own username.

You dont need X to be installed on your server to run X-programs. The client takes care of that.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: start programs over X with ssh using sudo

#10 Post by debiman »

Eazy wrote:
debiman wrote:
Eazy wrote:

Code: Select all

xauth add $(xauth -f ~username/.Xauthority list|tail -1)
this command is wrong. i hope it's just a typo.
The command is not wrong. You have substitute "username" with your own username.
well that's still wrong.

Eazy
Posts: 31
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

#11 Post by Eazy »

No its not
Edit:
Would you mind stop trolling in my thread?

Post Reply