There are some ways for accessing Raspberry Pi: access Pi directly or indirectly. You might at least try one of thus method for connecting your Pi to your PC.
The direct access involving access without any medium. You connect screen (LCD screen, for example), keyboards, mice, etc to your Pi. This way, your Raspberry Pi act as normal computer. You operate it like you operate your PC. This method has a drawback, whenever you want to use Pi you must provide appropriate input and output device (keyboard, mouse, screen).
Another way to access Pi is using indirect access. This method involving other medium to access Pi, technically a network. In this term, your Pi is connect to a network and you can access the Pi over the network. SSH and VNC are the good example of this. This method demand us to provide good network connection if you want a good connection.
Accessing Pi over network is good, you don’t need other peripheral / device such as keyboard, mouse, or LCD screen. If you want to do thing graphically you can use VNC (Virtual Network Computing). However, using VNC is somehow slow because the application and desktop environment are rendered both on your Pi and your desktop. VNC also require better network as it sends picture / screen image over time.
There is a better solution for this problem. Instead of rendering the graphic on Pi, why don’t we render it on our local computer? This way, Pi only send us minimal packet. Using this method, we can also use keyboard and mouse on our local computer, just like indirect access do.
In this article we will discuss about other way to remote accessing your desktop without VNC. We will use X.org which is used for Linux & Unix OS for GUI. For this article I use:
- Slackware64 14.0 on PC
- Raspbian Wheezy on Raspberry Pi
This article is written for Linux. If you use Windows, go here.
X Window System – Server & Client Architecture
X Window is originated at the Massachussetts Institute of Technology (MIT) In 1984. X11 is the system-level software infrastructure for the windowing GUI on Linux, *BSD, and other UNIX-like Operating System. It is designed to handle both local display, as well as across the network displays. X Window is a computer software system and network protocol that provides a basis for graphical user interfaces (GUIs) and rich input device capability for networked computers. It creates a hardware abstraction layer where software is written to use a generalized set of commands, allowing for device independence and reuse of programs on any computer that implements X.
X was designed from the beginning to be network-centric. It adopts a “client-server” model.
In the X model, the “X server” runs on the computer that has the keyboard, monitor, and mouse attached. The server’s responsibility includes tasks such as managing the display, handling input from the keyboard and mouse, and other input or output devices (i.e., a “tablet” can be used as an input device, and a video projector may be an alternative output device). Each X application (such as XTerm or Firefox) is a “client”. A client sends messages to the server such as “Please draw a window at these coordinates”, and the server sends back messages such as “The user just clicked on the OK button”.
In a home or small office environment, the X server and the X clients commonly run on the same computer. However, it is perfectly possible to run the X server on a less powerful desktop computer, and run X applications (the clients) on, say, the powerful and expensive machine that serves the office. In this scenario the communication between the X client and server takes place over the network.
This confuses some people, because the X terminology is exactly backward to what they expect. They expect the “X server” to be the big powerful machine down the hall, and the “X client” to be the machine on their desk.
It is important to remember that the X server is the machine with the monitor and keyboard, and the X clients are the programs that display the windows.
As stated before, the X window is using client/server model. Our communication would be on top of secure connection. Specifically, SSH (Secure SHell) connection are chosen to transport data (as a tunneling). Therefore, we should configure SSH server properly.
Now on your Raspberry Pi, configure SSH server. Obviously, you MUST install your SSH server program. Edit following file /etc/ssh/ssh_config, make sure these lines are not commented.
ForwardAgent yes ForwardX11 yes ForwardX11Trusted yes
/etc/ssh/sshd_config and edit the file so it has following line:
Restart the SSH Server.
Running X on your local machine, you should have more than 1 tty (teletype). Go to tty 1 (or any from 2 to 6) and you would see a black screen with login message there. Login with your account.
Next we need to make an X server. This server is another X server running on our local machine. This X server will manage our local screen output. We use this server to display anything from our X client, which is raspberry pi.
Now, the easiest way is to do is running X on display :1.
X :1 &; xterm
You should be brought to new tty with a blank screen and a “window” there.
Now connect to Raspberry Pi using SSH.
ssh -X [email protected]_ip_address
user is the username we will use and the raspberry_ip_address is the Pi’s IP address. Make sure you can access and you can login to Pi.
Once you are logged in, execute this to start the X.
lxsession & lxpanel &
Now, your tty should be drawn to your Raspbian’s LXDE.
When you want to back to your original desktop, press CTRL+ALT+F7. When you want to back to Pi’s desktop, press CTRL+ALT+F8.
This method require more resource on local computer as your local computer run 2 X Server at same time.
You should also note that you can only do swap display to change between these two display. Using VNC, you can display the content of Pi display as a window.desktop, linux, network, unix, X