Remote Viewing-Not Just a Psychic Power
The server command is simply
vncserver. When you run this command,
a directory named .vnc is created in your home directory if it doesn't
exist already. If a password has not been set yet for this instance of
the VNC server, it will ask you to enter one. It is saved in the file
passwd in encrypted form. If you want to change it, you can use the
vncpasswd. In this directory, you also
should find log files
for each instance of vncserver that you start, as well as a pid file
containing the PID of any currently running instances of vncserver.
The last file of interest is the xstartup file. This is the file that is used when you start vncserver to set up all the required options and also lay out what will be run on the vncserver desktop. The defaults on my Ubuntu system look like this:
#!/bin/sh xrdb $HOME/.Xresources xsetroot -solid grey #x-terminal-emulator -geometry 80x24+10+10 -ls -title ↪"$VNCDESKTOP Desktop" & #x-window-manager & # Fix to make GNOME work export XKL_XMODMAP_DISABLE=1 /etc/X11/Xsession
So in this case, it sets the background to gray and then tries to run whatever session is defined in the global script Xsession. This is where you can do some editing and make it your own. I prefer Fluxbox as a window manager on smaller screens. So you can simplify this to:
#!/bin/sh xrdb $HOME/.Xresources startfluxbox
Starting this gives you a nice-looking desktop running Fluxbox. If the
client that is going to be connecting to this has to deal with a smaller
screen size (like on a Netbook), you can set the desktop size on the
command line with the
-geometry option. You also can set the color
depth of the virtual desktop with the
-depth option. So, to set up a
server that looks nice when I connect to it from my Netbook, I would use
vncserver -geometry 800x600
Now, what about the other end? There are two general classes of vncviewer applications, GUI and command line. The GUI versions, like the most common ones for Mac OS X and Windows, have point-and-click access to all the relevant options. They also have them in different locations, depending on who wrote your particular favorite viewer. Because VNC is a protocol (kind of like FTP or HTTP), there is a great deal of variation in what you get from the various implementers. Let's look at the command-line versions here and see what you can do with those. The GUI versions should have comparable options available. To connect to a vncserver, you would run:
hostname is either the true hostname of the remote machine or its
port is the port number on which the vncserver is listening,
starting at 1. This number is added to the default starting port number
5900, so the actual network port number in this case is 5901. This will
try to connect to the given server, and it will ask for a password if
one had been set during vncserver's startup. Then, you get a nice
Figure 2. Fluxbox Running under vncserver
There are lots of options for changing various parts of what is being transmitted, such as the encoding algorithm, the compression level and the quality level. Playing with these options can improve your session's responsiveness, potentially at the cost of some image quality. Depending on what work you are trying to do, this may not be a trade-off you are willing to make.
Although you can force some kind of authentication on VNC, that may
not be enough in these security-conscious days. You may have to work
with a remote machine that sits behind a firewall that allows only SSH
traffic. What can you do? VNC allows for tunneling of the protocol over an
SSH connection by using the
-via gateway option. This gateway machine
is the machine that you are SSHing in to for the tunneling. If this
is the same machine as your vncserver, the command would look like this:
vncviewer -via firstname.lastname@example.org localhost:1
This tells vncviewer to
ssh to somehost.com as user "user", then connect
to vncserver on the localhost to somehost.com—in other words, somehost.com
itself. There is no reason that these need to be the same machine. This
means you could connect to a vncserver on a machine behind a security
gateway machine. In this case, it would look like this:
vncviewer -via email@example.com someotherhost.com:1
Be aware that VNC still will ask you to authenticate after the SSH session has been established.
Hopefully, this article has provided some options for those times when you just can't live without a nice graphical interface. Even when you are forced to squeeze through an SSH connection, you still can have all of that great GUI goodness. If you know of other ways of getting a graphical interface on a remote machine, I would love to hear about them.
Joey Bernard has a background in both physics and computer science. This serves him well in his day job as a computational research consultant at the University of New Brunswick. He also teaches computational physics and parallel programming.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Profiles and RC Files
- Astronomy for KDE
- Maru OS Brings Debian to Your Phone
- Understanding Ceph and Its Place in the Market
- Snappy Moves to New Platforms
- What's Our Next Fight?
- Git 2.9 Released
- OpenSwitch Finds a New Home
- The Giant Zero, Part 0.x
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide