Run GParted over SSH
I am using a laptop with Ubuntu 14.04 and I started building a Samba server at home.I am using Ubuntu-Server 14.04 for this machine.
I use Webmin and SSH (depending on the job) to configure my server.
Recently I googled "run GParted over SSH". I didn't knew that was possible, so I gave it a try. I installed GParted (on server) but when I enter
sudo gparted
I get the error:
"Gtk-WARNING **: cannot open display:"
I vainly followed all guides I could find like: http://www.ossramblings.com/changing-linux-server-partitions-gui
I also tried:
sudo -E gparted
- Setting X11Forwarding yes
- export DISPLAY=
Any other ideas? Thank you all for your time and replies!
The problem is that when you use sudo, it creates a new environment with no X settings.
There are two options: first, you can use sudo -E gparted
to try preserving the environment, try it, if this works it's probably the safest option.
If not, you'd need to configure your server's root account to allow logging in through ssh, so that you can ssh root@server
, which should set the appropriate forwarding and environment.
First, on the server, in /etc/ssh/sshd_config
, ensure it has:
X11Forwarding yes
PermitRootLogin without-password
Next, add the ssh public key from your client to the root account on the server. If you can already ssh to the server without password with your normal user, then use sudo -i
to start an interactive root session. Then:
-
ssh localhost
. This is just so that an initial.ssh
directory is created. - Copy the
authorized_keys
file from the normal user:cp /home/normaluser/.ssh/authorized_keys ~/.ssh
Now from the remote system try ssh -v root@server
. You should be able to log in with no password. Check that the output shows X forwarding has been enabled. Then you should be able to run gparted
remotely.
Also, it goes without saying, but mucking around with a remote system's partitions is risky; ensure you have a backup of important data in case a disaster happens :)