I need that that application will start on my laptop screen when I launch, for example, "xterm". So if i start xterm in SSH my laptop must show me xterm on the screen, but it says, "DISPLAY is not set". What must i do with that?
1 Answers
You must turn on X forwarding while connecting via SSH. Use -X parameter to ssh command, like:
ssh -X 10.0.0.1
Of course your local computer (the one you are connecting from) needs to have X server running.
The X forwarding must be also enabled on the SSH server for this to work. So if the above command doesn't work, you need to enable X forwarding. You must do it on the remote machine, ie. you need to first connect there via ssh without -X.
Edit the file /etc/ssh/sshd_config (you must do it from root, so eg. use the command sudo -e /etc/ssh/sshd_config for example). Find the line that contains the string X11Forwarding. It may be commented out (# at the beginning of the line), like this:
#X11Forwarding no
Change the line so that it looks like the following (if there was no such line in the file previously, just add it):
X11Forwarding yes
(note no # at the beginning of line and yes instead of no). Save the file and restart the ssh server:
sudo service ssh restart
After this, ssh -X should work.
- 9,367
- 2
- 16
- 42
-
You are right of course :) BTW, there's probably a mistake in the article you linked to. They tell to edit the file `/etc/ssh/ssh_config`, and this file contains configuration of the ssh client, not the server. For server config, one needs to edit the file `/etc/ssh/sshd_config`. – raj Jan 24 '21 at 21:49
-
1(I can't edit) They also tell to use the string `ForwardX11` in the file while it's actually `X11Forwarding`. I have updated my answer to include enabling X11 forwarding on the server. – raj Jan 24 '21 at 22:01
-
Excellent. Voted now that it's complete. – KGIII Jan 24 '21 at 22:11
-
I mean, I want the xterm start on LAPTOP screen when I start it on phone using ssh. – SsNipeR1 Jan 28 '21 at 13:29
-
Yes, that's exactly what I'm writing about. You need to forward X11 over ssh. – raj Jan 28 '21 at 13:30