LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-11-2024, 10:02 PM   #1
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
How to run gparted through ssh -X not root user


I already have a simple workaround (simply unplug the computer and move it to where I have a monitor), but I'm curious if there's some simple thing I'm missing.

I have a computer without a monitor, which I wanted to use for some drive maintenance tasks - resizing/moving partitions, cloning, etc. However, I always restrict ssh to NOT allow root login, and I prefer not to change that.

So, I was thinking this would work:

Code:
kuo@ella:~$ ssh -X dlit
kuo@dlit:~$ gparted
-bash: gparted: command not found
kuo@dlit:~$ /usr/sbin/gparted
localuser:root being added to access control list
xhost:  must be on local machine to add or remove hosts.
Error executing command as another user: No authentication agent found.
localuser:root being removed from access control list
xhost:  must be on local machine to add or remove hosts.
kuo@dlit:~$ su -
Password: 
root@dlit:~# gparted
Unit tmp.mount does not exist, proceeding anyway.

(gpartedbin:2091): Gtk-WARNING **: 21:53:39.709: cannot open display: 
root@dlit:~# exit
logout
kuo@dlit:~$ su
Password: 
root@dlit:/home/kuo# /usr/sbin/gparted
Unit tmp.mount does not exist, proceeding anyway.
sh: 1: dmidecode: not found
X11 connection rejected because of wrong authentication.

(gpartedbin:2196): Gtk-WARNING **: 21:54:09.327: cannot open display: localhost:10.0
I have no problem running a graphical X program as my normal user, but when I "su" to root, root can't start up a graphical X program.

I mean, this isn't a pressing problem for me, I was able to work around and attach this computer elsewhere to a monitor when I had the opportunity (this monitor is attached to a computer used by others).

But it's a "nice to have" for me if I'm just missing something simple.

Thanks!

Last edited by IsaacKuo; 01-11-2024 at 10:04 PM.
 
Old 01-12-2024, 12:54 AM   #2
enigma9o7
Senior Member
 
Registered: Jul 2018
Location: Silicon Valley
Distribution: Bodhi Linux
Posts: 1,388

Rep: Reputation: 560Reputation: 560Reputation: 560Reputation: 560Reputation: 560Reputation: 560
sounds like a policykit issue, it should prompt you for password when you run gparted.
 
Old 01-12-2024, 01:59 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
you need to understand how X works. X is started as user, therefore root cannot access it by default (cannot open display). If you really want to do that you need to set at least two variables (as root):
Code:
DISPLAY=(display variable of the user)
XAUTHORITY=~/.Xauthority (Xauth file of the user)
 
1 members found this post helpful.
Old 01-12-2024, 06:39 AM   #4
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546

Original Poster
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by pan64 View Post
you need to understand how X works. X is started as user, therefore root cannot access it by default (cannot open display). If you really want to do that you need to set at least two variables (as root):
Code:
DISPLAY=(display variable of the user)
XAUTHORITY=~/.Xauthority (Xauth file of the user)
Cool, thanks so much! This is what worked for me:

Code:
kuo@ella:~$ ssh -X dlit
kuo@dlit:~$ echo $DISPLAY
localhost:10.0
kuo@dlit:~$ su -
Password: 
root@dlit:~# export DISPLAY=localhost:10.0
root@dlit:~# export XAUTHORITY=/home/kuo/.Xauthority 
root@dlit:~# gparted
Unit tmp.mount does not exist, proceeding anyway.
======================
libparted : 3.2
======================
Worked like a charm!
 
Old 01-12-2024, 06:46 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
You are welcome. If you think your problem is solved please mark the thread solved.
(also if you wish to say thanks just click on yes)

Last edited by pan64; 01-12-2024 at 06:53 AM.
 
Old 01-12-2024, 07:28 AM   #6
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546

Original Poster
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by pan64 View Post
You are welcome. If you think your problem is solved please mark the thread solved.
(also if you wish to say thanks just click on yes)
Thanks so much! I had to run out the door so I didn't click on it yet. Done now, though!
 
  


Reply

Tags
gparted, ssh x11 forwarding



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
LXer: Disable SSH root Login And Permit The root User Via su User In Linux LXer Syndicated Linux News 0 04-14-2019 07:28 AM
LXer: SystemRescueCd and GParted Live Now Based on GParted 0.24.0, Detect ZFS Filesystems LXer Syndicated Linux News 0 10-30-2015 08:42 AM
LXer: GParted Live Switches to Systemd, Includes GParted 0.22.0 LXer Syndicated Linux News 0 03-25-2015 08:03 AM
LXer: GParted Live CD 0.13.0-1 Is Based on GParted 0.13.0 LXer Syndicated Linux News 0 07-16-2012 04:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:01 PM.

Main Menu
Advertisement
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
Twitter: @linuxquestions
Open Source Consulting | Domain Registration