This article is probably not only for absolute beginners, so many Linux guys do not know they can just execute a GUI program on their remote machine but the output of the graphics to be drawn in the local display, it’s like your local display is connected to the remote computer through the network. And you do not need any special software like VNC Client/Server, TeamViewer – all you need is the OpenSSH package you probably have when managing a remote machine. And it is absolutely secure because all the communication is performed within ssh.
Suppose you have a machine, which has some GUI capabilities (you know if we speak for servers, not all servers need the GUI, but in some cases we need it) and you want to execute a graphical program on the remote.
Here is how you can login to be sure you can execute the program remotely:
ssh -o ForwardX11=yes -o ForwardAgent=yes -o ForwardX11Trusted=yes [USER]@[IP]
And you can also execute a remote command with the ssh:
ssh -o ForwardX11=yes -o ForwardAgent=yes -o ForwardX11Trusted=yes email@example.com 'virtualbox'
This command will execute virtualbox on your remote machine with login firstname.lastname@example.org and the output the display on your local machine.
Here are some examples. Gentoo Desktop using KDE with konsole get to the remote machine on our local network 198.160.245: