start programs over X with ssh using sudo

If none of the more specific forums is the right place to ask

start programs over X with ssh using sudo

Postby Eazy » 2018-06-11 18:17

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: 14
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

Postby Eazy » 2018-06-14 16:36

Really, no one?
Eazy
 
Posts: 14
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

Postby wizard10000 » 2018-06-14 18:34

You'd use gksudo or gksu, same as if you were on your local machine.
we see things not as they are, but as we are.
-- anais nin
User avatar
wizard10000
 
Posts: 1292
Joined: 2011-05-09 20:02
Location: everywhere i go, there i am!

Re: start programs over X with ssh using sudo

Postby Head_on_a_Stick » 2018-06-15 05:14

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
User avatar
Head_on_a_Stick
 
Posts: 7906
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: start programs over X with ssh using sudo

Postby Eazy » 2018-06-26 20:43

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.
Eazy
 
Posts: 14
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

Postby Head_on_a_Stick » 2018-06-27 05:12

^ 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.
User avatar
Head_on_a_Stick
 
Posts: 7906
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: start programs over X with ssh using sudo

Postby Eazy » 2018-06-27 18:54

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.
Eazy
 
Posts: 14
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

Postby milomak » 2018-06-27 19:45

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?
iMac - MacOS and Windows 10 (Bootcamp)/ Debian Sid (External SSD)
Laptop (64-bit) - Debian Sid, Win10,
Kodi Box - Debian Sid
milomak
 
Posts: 1763
Joined: 2009-06-09 22:20

Re: start programs over X with ssh using sudo

Postby debiman » 2018-06-28 10:53

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).
User avatar
debiman
 
Posts: 2818
Joined: 2013-03-12 07:18

Re: start programs over X with ssh using sudo

Postby Eazy » 2018-06-28 13:00

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.
Eazy
 
Posts: 14
Joined: 2009-07-01 20:19

Re: start programs over X with ssh using sudo

Postby debiman » 2018-06-29 15:20

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.
User avatar
debiman
 
Posts: 2818
Joined: 2013-03-12 07:18

Re: start programs over X with ssh using sudo

Postby Eazy » 2018-06-29 15:26

No its not
Edit:
Would you mind stop trolling in my thread?
Eazy
 
Posts: 14
Joined: 2009-07-01 20:19


Return to General Questions

Who is online

Users browsing this forum: No registered users and 7 guests

fashionable