x11vnc server installation in Centos7 and Manjaro and remote connection via android vnc clients

0
2309
(Last Updated On: May 2, 2018)

Welcome to this exciting article where we get to install x11vnc server on Centos7 and Manjaro. After that, we shall use two android vnc clients (VNC Viewer and androidVNC) to connect to the servers.

“Mountaintops are for views and inspiration, but the fruit is grown in the valleys.”
-Billy Graham

Introduction

The notion of controlling your computer via your Android device is absolutely amazing. The set up can be a huge convenience for you especially if you would not like to carry your computer around while monitoring critical processes running in it. The good news is that it is possible to control your laptop or any network-enabled computer through your pocket smartphone friend. After trying out many packages and applications, the following set up worked for me in my Centos7 and Manjaro Linux boxes. The set up here is that the phone and the machines are on the same subnet.

1. Centos7
The first step was the installation of x11vnc server on the Centos7 box. The easiest way to accomplish this is by going to software applications app and searching for x11vnc. Click on the installbutton once you find it.

After it has successfully installed, look for the application and launch it. A GUI prompt will be presented to you titled Select x11vnc port. On this prompt, choose the port you would wish the server to be running on. I will be using.port 5901 After this choose Listen on Localhost (this is a good security measure instead of exposing it to your LAN) and click OK. A new prompt will be called after a short while with new options to set.

Check the relevant options that will suit your needs here. Enter a password and verify it. Click Apply and OK after you are done. At this point, your x11vnc server is running.
The second step is all about your phone, I hope you are ready to get this feature for your enjoyment.

Launch play store and search for ConnectBot and install it when you get your hands on it. This is an application that is going to help us tunnel our vnc requests via ssh by forwarding our ports running in the Centos7 server locally.

After you have successfully installed the app the next step is keying in the IP address and the rest of the essential credentials.

Make sure you ssh into your computer at this point and check out if it works.

When connected, click on the menu and create the forward as follows:
Touch Port Forwards on the screen.

Touch + button or Add port forward menu depending on your phone type
Key in the following data on the blank spaces.
Nickname: tech
Type: Local
Source Port: 5901
Destination: localhost:5900

A very important step is the ports you enter. Make the source port the port you chose on the GUI [5901 in this case and the destination as any port like 5900].

The source port is the port the server opens and allows us to access the screen of the computer. After entering the ports, please disconnect ssh and reconnect again with the updated port data.

We know the process might have been long but one more step is all we have before we can control our computers via our android phones. Let us go:
Once again, launch play store and look for androidVNC.

Install, launch and key in the following data on the spaces it will present.
Password: (Rememeber password we set up on the x11vnc gui prompt? Enter it here and check the Keep box so that you don’t keep keying it in every time)
Address: 127.0.0.1 (or localhost)
Port: 5901 (This should be the source port you keyed into ConnectBot, do not forget about this or else you won’t be able to get connected)

Leave the rest of settings blank or default then touch on the Connect button and there your current computer screen will appear on your android phone. Well done guys. This is the point where you can grab a cup of Java.

2. Manjaro

a. Installation of x11vnc.
The package is available in the repositories, therefore invoke the following on your terminal

# sudo pacman -S x11vnc

b.Set Password
Use

# x11vnc -storepasswd

You will be prompted to enter a password and verify it. Please enter a suitable password here. The password will be saved in /home/user_name/.vnc/passwd
Another way is by invoking the following commands where password is your chosen password. The password will be stored in the ~/.x11vnc/passwd file.

# mkdir ~/.x11vnc
# x11vnc -storepasswd password ~/.x11vnc/passwd

c. Create A Log File
You can create a log file manually in /home/user_name/.vnc/x11vnc.log

d. This is a command that you can invoke to start the x11vnc server (please make sure you use the user name you set in the “user_name” part)

# x11vnc -nap -wait 50 -noxdamage -rfbauth /home/user_name/.vnc/passwd -display :0 -nocursor -forever -o /home/user_name/.vnc/x11vnc.log -bg

The above command will return a result that looks like:
PORT=5903 or PORT=5900

Also, note that you can change to-display :0 another value like -display :1 if you like. The port you will forward will be output on the screen e.g PORT=5903 as mentioned. This is the port that will be designated to the source port in ConnectBot android app.
Launch play store and search for ConnectBot and install it when you get your hands on it. This is an application that is going to help us tunnel our vnc requests via ssh by forward our ports running in Manjaro locally.

After you have successfully installed the app the next step is keying in the IP address and the rest of the credentials. ssh into your computer at this point and check out if it works just like before. When connected, click on menu and create the forward as follows:
Touch Port Forwards on the screen.

Touch Add port forward menu depending on your phone type
Key in the following data on the blank spaces.
Nickname: tech
Type: Local
Source Port: [In case the last command you invoked on the terminal returned PORT=5901, assign 5901 here. The destination value you will key in the ConnectBot android application becomes 5902.
Destination: localhost:5902. After you set up the port forwards, make sure that you disconnect all connections and reconnect again so that we use the updated forwarded ports on the vnc android client.

The next step is setting up your android vnc client. For this setup, we are going to use Android VNC Viewer for various purposes. Let us roll our sleeves and go:

Launch play store and look for.VNC Viewer
Install, launch and key in the following data on the spaces it will present.

On the address field enter 127.0.0.1:5901 (note that we have used the source port and not the destination port). Refer to the source port you entered in your running ConnectBot and use the port to bind the local loopback address shown as 127.0.0.1:5901. I emphasize this because it is very important for the connection to succeed.
Enter any name for the Name value then click save and connect thereafter.

You will be asked for the password you entered when prompted after invoking the # x11vnc -storepasswd command

Conclusion

Thank you for visiting and following through the article. I hope controlling your desktop or any other computer via your android phone will be much fun. Keep the spirit of learning high.