Is X forwarding possible on a host machine if it is already running an x session?
So I am running Deb 9.6 and XFCE and I often ssh into it from my MacBook, because the battery on it isn’t that great so I leave it plugged in , in another room. I would like to try x forwarding. I tried looking at solutions such as editing my sshd confit but I still get an error. My question is can I x forward if there’s an instance of an X session already running? If not, what steps should I take?
|
Your post is a bit funny: Can I do this, if not what should I take....
Yes, you can do that, but without knowing your config hard to say anything. So please post relevant info like how did you edit your sshd config, what error did you get .... |
Quote:
Are you trying to see your desktop, or see a particular app? If you want to see a desktop, you need something like VNC. But that's probably pointless. If you can ssh into the remote machine, try a graphic command like these. The final & will run it in the background so you get your prompt back. If X is being forwarded, it'll run remotely but display on the local desktop (though any browser will be sluggish). Code:
firefox & Code:
mkdir ~/remv Code:
mplayer ~/remv/some-movie.mp4 |
Heres my config, or at least the section I assume you're interested in.
Code:
#AllowAgentForwarding yes Code:
coop@coop:~$ xclock |
Log into your remote machine with ssh. In the remote shell, enter this command:
Code:
echo $DISPLAY Code:
localhost:11.0 |
Thanks ken, I just tried it, and it came back blank.
|
I assume the configuration file you posted above is the server i.e. etc/ssh/sshd_config. You still need to allow forwarding by setting a similar setting in the system wide configuration /etc/ssh/ssh_config, users ~/.ssh/config file or via the command line option -X.
Did you restart the ssh server after making changes to the sshd_config file. Just to lend a helping hand... |
Thanks I’ll try that! Do I have to uncomment those lines?
|
Well, the client setting is configured on the client computer i.e. your Mac and what I posted is for linux but should be similar.
I would try the -X command line option first. ssh -X username@server_name |
Code:
coop@coop:~$ echo $DISPLAY Code:
coopmba:~ cooper$ cat /etc/ssh/ssh_config Code:
coop@coop:~$ cat /etc/ssh/sshd_config |
Quote:
Your remote machine is the ssh server, running a daemon, but is the X window client. Your local machine is the ssh client but is the X window server. The sshd_config file you showed seems to have X11Forwarding set correctly. It should be on the remote machine. And ssh_config has ForwardX11 set correctly. It should be on the local machine. If you edited sshd_config on the remote machine but haven't restarted the daemon, you need to do that. If your system uses systemctl, this command should do that (on the remote machine): Code:
sudo systemctl restart sshd.service |
Ah yes I flipped them thanks for the clarification. I'll amend it and report back.
|
okay so I've mirrored both the ssh and sshd configs on both systems to be safe. I also have restarted the daemons on both systems, yet I still get
Code:
coop@coop:~$ xclock Code:
coop@coop:~$ echo $DISPLAY |
One more thing you can do is use -v to verify that you see:
debug1: Requesting X11 forwarding with authentication spoofing. If you don't see that, add the -X switch. If you still don't see it, your remote machine isn't requesting X. Then verify you see either: X11 forwarding request failed on channel 0 or (you'll have to use -vv to see this): debug2: X11 forwarding request accepted on channel 0 If the request failed, then the remote machine has an issue. If the request is accepted and you still can't use X, that's odd. |
how did you get that shell (where you executed xclock)?
|
All times are GMT -5. The time now is 12:00 AM. |