xdotool errors over ssh on Ubuntu 20.04 LTS

I am trying to use xdotool over ssh on Ubuntu 20.04 LTS. It works perfectly from within a terminal window when logged in locally, but over ssh it displays the following error from using any command:

$ xdotool click 1
Error: Can't open display: (null)
Failed creating new xdo instance

Looking up this error the fix people suggest is exporting the DISPLAY variable before running it, but for me this only leads to a new line added to the error message:

$ export DISPLAY=:0.0 && xdotool click 1
No protocol specified
Error: Can't open display: (null)
Failed creating new xdo instance

Looking for "No protocol specified" errors for xdotool the only other suggestion I've been able to find is also adding export XAUTHORITY=/home/[username]/.Xauthority to the command as well but that makes no difference for me. It's probably worth noting that I don't have an .Xauthority file in my home directory either (and creating an empty one just to see if it made a difference did not help). I'm not really familiar with X server stuff so I don't know if these things have changed since the results I'm finding where written.

I would appreciate any advice in trying to get this to work.


Solved: As pointed out by N0rbert I was missing the -X option when connecting over SSH. That's all I needed to include.

2

2 Answers

You have to run ssh with -X option like below:

ssh -X user@hostname

and then execute "graphical" commands as usual.

1

The thing is this will control the system that is connected via SSH and not the Host you want to Control. For a example I login with the ssh -X server@192.192.192.192 and then tell xdotool to move the mouse instead of moving the mouse on the Server it moves the mouse on the client that is connected.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like