“No X11 DISPLAY variable was set” error – Amazon EC2 / SSH

amazon ec2aptputty

I'm trying to install APT on an Amazon EC2 through PuTTY. I've uploaded APT, found here, and followed these instructions to install. However, when I run sh install-linux64-apt.sh in the proper directory, the result is an error:

No X11 DISPLAY variable was set […]

So I looked this problem up, and found an answer here. However, running setenv DISPLAY :0.0 or export DISPLAY=:0.0 both result in a failure of some sort (the first fails, and the second does nothing at all). So that answer doesn't help much.

What's the solution for this case?

Best Answer

export DISPLAY=:0.0 normally defines a graphics display physically attached to the computer. You're remotely connecting to the EC2 instance, so that's not what you want.

SSH, including putty, has an option to forward X from the remote system to your local display. It will set the DISPLAY environment variable for you. With putty, Go into Configuration->Connection->SSH->X11 and enable X11 forwarding.

However, for that to work, you need to have an X server on your local system. If your local system is Linux, and you're using the graphical console, then you should be fine. If your local system is Windows, then you probably don't have an X server. There is X server software for Windows. Or you could use MobaXTerm, which is an SSH client like putty with a built in X server.

Related Question