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.

  • 1
    Did you forget -X in ssh -X ?
    – N0rbert
    May 19, 2020 at 8:03
  • @N0rbert thank you! I wasn't even aware of that option. I completely glossed over it in the examples I was reading. Thank you!
    – user1084331
    May 19, 2020 at 8:39

2 Answers 2


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

ssh -X user@hostname

and then execute "graphical" commands as usual.

  • can confirm this works Jan 11, 2022 at 13:28

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 [email protected] 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.

You must log in to answer this question.