Linux – Unable to open display “:0” on ubuntu 11.04 (with unity)

imagemagicklinuxsshUbuntu

I'm connecting to a ubuntu 11.04 through ssh, and I'm trying to run this command(is a Image Magick command):

*This command saves any visible window on an X server and outputs it as an image file.

sudo import -window root -display :0 screen.png
No protocol specified import: unable to open X server `:0' @ error/import.c/ImportImageCommand/362.

I think that the problem is unity, because if I try this in ubuntu before 11.04 it runs without problems(The older versions uses gnome instead of unity). Somebody knows how to connect to the x server in ubuntu 11.04?

Thanks in advance.

Best Answer

try running

xhost +localhost

On the server before grabbing the window.

Edit

BTW you need to be logged in as the same user whom has logged into the X server and set DISPLAY before running xhost.

Related Topic