
Remote Desktop Setup (VNC, x11vnc)
With Linux, life becomes more interesting, I would even say more experimental!
I was drawn to experimenting with ssh, and what I got in the end - access from work to my home computer - I really liked it! Still - it’s cool to manage your home computer, update it, etc. I talked with the girl even with the help of festival)))
However, I wanted to go further, I wonder if it is possible to configure remote access to the desktop, as RAdmin allows in Windows? Of course it is possible! You just need to configure it)) I
rummaged on the Internet, found several articles about VNC - Virtual Network Computing , I decided to make such a fortune at home!
To do this, you first had to install several utilities:
These utilities are needed directly to start a remote server (vnc4server) and connect to it from a remote client (xvnc4viewer).
Installed! Now the matter remains small: first you need to start the vnc server, and then connect to it.
To start a remote server, you need to type in the console.
If this is the first start of vncserver in the system with this user account, then you must enter the password that the clients will use when connecting, after which the server will start, which will be available on port 5901. By the way, when When the server is launched, the display (virtual) number will be displayed in the console on which it will be available, the countdown is from 1 (since 0 is the current display). Launch Example: Here is the line
New 'Voyageur: 1 (igor)' desktop is Voyageur: 1 just says that my computer started the server on display 1, it is available on port 5901.
If you run vncserver again, the new terminal server will load: 2 on port 5902, etc.
Now try to access this server from a remote machine. To do this, enter the command in the console of the remote client:
In this command, __hostname__ is the domain name or ip of the machine on which the remote server is running. Next, you will need to enter a password and as a result, approximately this window will appear:

To be honest, I expected a little bit)) I started to understand, and it turned out that vncserver starts only a new session, and does not connect to the current one, which is what virtual displays are for. And in this session, twm (Tab Window Manager for the X Window System) and xterm are launched.
By the way, all this stuff is launched from the ~ / .vnc / xtartup script, which can be edited by deleting unnecessary ones and adding your own launch lines for necessary applications. At the very top of the script there is a small comment: That is, to get a normal desktop, you need to uncomment 2 lines. I uncommented them, but nothing good came of it. I looked at this twm, and decided that it was impossible to work with this squalor. I installed fluxbox (takes only 6 MB) and replaced the line in the xstartup script
on
In the end, it turned out like this:

Normal for work. But not ice! The opera can be launched, some more applications, but not all (kde applications break out)! I tried to run kde instead of fluxbox'a, but it didn’t work ... The login greeting is played, but a window crashes out with a plasma crash and that's it, a black screen, a curtain ...
As a result, I got remote access, but not as I wanted! I wanted to have access to the current desktop, and not to the mythical display 1, which loads fluxbox, but not kde.
What to do? We must dig more !!!
I looked in the repositories for packages whose name contains “vnc”, the list was not very large, I started reading comments on utilities and libraries ... At the very end of the list I saw this line:
Very similar to what I need!
I installed x11vnc ... man in this utility is notable, several thousand lines)) After a little study of it, I more or less understood the startup procedure and the purpose of the utility.
So, x11vnc is actually a remote server (like vncserver), but it allows you to access an existing X-session!
On the machine you need to connect to:
This command will allow you to borrow a password for connecting to the server from the ~ / .vnc / passwd file (here lies the password that was set when vncserver was first launched). Next, directly run x11vnc:
The -usepw option enables the use of a password when connecting to the server, -display: 0- starts the server on the zero display (so where the current X-session is open).
Now we can connect to the current X-session from the remote machine by completing
and entering the password.

When closing the remote desktop window, x11vnc also ends (on the server)
Thus, I got what I wanted))))
Finally, I will give a few options for the vncserver, x11vnc and vncviewer utilities that facilitate traffic and life))
vncserver:
x11vnc:
vncviewer:
PS By the way, if you want x11vnc to start automatically, then you need to add it to autoload: in the System Settings, select the Autoload item (on the second tab), add a script there
and indicate that it should start before KDE starts!
I was drawn to experimenting with ssh, and what I got in the end - access from work to my home computer - I really liked it! Still - it’s cool to manage your home computer, update it, etc. I talked with the girl even with the help of festival)))
However, I wanted to go further, I wonder if it is possible to configure remote access to the desktop, as RAdmin allows in Windows? Of course it is possible! You just need to configure it)) I
rummaged on the Internet, found several articles about VNC - Virtual Network Computing , I decided to make such a fortune at home!
To do this, you first had to install several utilities:
sudo aptitude install vnc4-common vnc4server xvnc4viewer
These utilities are needed directly to start a remote server (vnc4server) and connect to it from a remote client (xvnc4viewer).
Installed! Now the matter remains small: first you need to start the vnc server, and then connect to it.
To start a remote server, you need to type in the console.
vncserver
If this is the first start of vncserver in the system with this user account, then you must enter the password that the clients will use when connecting, after which the server will start, which will be available on port 5901. By the way, when When the server is launched, the display (virtual) number will be displayed in the console on which it will be available, the countdown is from 1 (since 0 is the current display). Launch Example: Here is the line
igor@Voyageur:~$ vncserver
New 'Voyageur:1 (igor)' desktop is Voyageur:1
Starting applications specified in /home/igor/.vnc/xstartup
Log file is /home/igor/.vnc/Voyageur:1.log
New 'Voyageur: 1 (igor)' desktop is Voyageur: 1 just says that my computer started the server on display 1, it is available on port 5901.
If you run vncserver again, the new terminal server will load: 2 on port 5902, etc.
Now try to access this server from a remote machine. To do this, enter the command in the console of the remote client:
vncviewer __hostname__:1
In this command, __hostname__ is the domain name or ip of the machine on which the remote server is running. Next, you will need to enter a password and as a result, approximately this window will appear:

To be honest, I expected a little bit)) I started to understand, and it turned out that vncserver starts only a new session, and does not connect to the current one, which is what virtual displays are for. And in this session, twm (Tab Window Manager for the X Window System) and xterm are launched.
By the way, all this stuff is launched from the ~ / .vnc / xtartup script, which can be edited by deleting unnecessary ones and adding your own launch lines for necessary applications. At the very top of the script there is a small comment: That is, to get a normal desktop, you need to uncomment 2 lines. I uncommented them, but nothing good came of it. I looked at this twm, and decided that it was impossible to work with this squalor. I installed fluxbox (takes only 6 MB) and replaced the line in the xstartup script
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
twm &
on
fluxbox &
In the end, it turned out like this:

Normal for work. But not ice! The opera can be launched, some more applications, but not all (kde applications break out)! I tried to run kde instead of fluxbox'a, but it didn’t work ... The login greeting is played, but a window crashes out with a plasma crash and that's it, a black screen, a curtain ...
As a result, I got remote access, but not as I wanted! I wanted to have access to the current desktop, and not to the mythical display 1, which loads fluxbox, but not kde.
What to do? We must dig more !!!
I looked in the repositories for packages whose name contains “vnc”, the list was not very large, I started reading comments on utilities and libraries ... At the very end of the list I saw this line:
p xvnc4viewer - Virtual network computing client software for X
Very similar to what I need!
I installed x11vnc ... man in this utility is notable, several thousand lines)) After a little study of it, I more or less understood the startup procedure and the purpose of the utility.
So, x11vnc is actually a remote server (like vncserver), but it allows you to access an existing X-session!
On the machine you need to connect to:
x11vnc -storepasswd
This command will allow you to borrow a password for connecting to the server from the ~ / .vnc / passwd file (here lies the password that was set when vncserver was first launched). Next, directly run x11vnc:
x11vnc -usepw -display :0
The -usepw option enables the use of a password when connecting to the server, -display: 0- starts the server on the zero display (so where the current X-session is open).
Now we can connect to the current X-session from the remote machine by completing
vncviewer __hostaname__:0
and entering the password.

When closing the remote desktop window, x11vnc also ends (on the server)
Thus, I got what I wanted))))
Finally, I will give a few options for the vncserver, x11vnc and vncviewer utilities that facilitate traffic and life))
vncserver:
- -kill: n - terminates the terminal server on display n (port 590n), if it was previously launched
- -geometry 800x600 - sets the size of the created desktop (by default 1024x768)
- -depth depth - sets the color depth in bits, the default is 16 bits, can be changed to 8, 15, 24
- To start a VNC server with a specific number (display), use the vncserver command: n
x11vnc:
- -q - reduces the output of debugging information to stderr
- -forever - this option does not shut down the x11vnc server when the first client disconnects, but waits for the next connections
vncviewer:
- -geometry 800x600 - sets the size of the window in which the remote desktop will be displayed. If the specified size is smaller than the size of the remote table, then scroll bars will appear
- -compressionlevel n - sets the data compression level. The value of n varies from 0 to 9, 9 - the best compression (quality, respectively, worse)
- -quality m - affects the quality of the picture. m varies from 0 to 9, 0 - the worst image quality (less traffic)
- -depth depth - if the X-server supports different color depths, then you can try to choose the optimal value (in bits)
- -viewonly - an option that allows the connected user to only observe what is happening on the remote machine, controls (mouse, keyboard) are not available
PS By the way, if you want x11vnc to start automatically, then you need to add it to autoload: in the System Settings, select the Autoload item (on the second tab), add a script there
x11vnc -usepw -display :0 -q -forever &
and indicate that it should start before KDE starts!