I have an X instance running on my server computer, and on occasion I connect to it remotely via TeamViewer. Once in a while TeamViewer crashes and I cannot restart it remotely. Is there a way to login to my running X instance through ssh, and restart TeamViewer remotely?
An X program needs two pieces of information in order to connect to an X display.
You're trying to act on the windows that are displayed on your desktop. If you're the only person using your desktop machine, it's very likely that the display name is
If this is a one-shot, you can detect the values of
A long-term, automatic solution is to copy cookies when you log into your desktop X session. Add the following lines to
Then you can run programs on your remote X display simply by setting
This answer is adapted from a more complete answer to a similar question on Unix Stack Exchange.
Probably the easiest way is to remotely (via SSH) start a vncserver on the relevant display. After that use SSH tunneling to connect a vnc client from your remote machine through the SSH connection to the VNC server.