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.
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
|Trying to Tame the Tablet||May 08, 2013|
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- New Products
- Android is Linux -- why no better inter-operation
2 hours 6 min ago
- Connecting Android device to desktop Linux via USB
2 hours 34 min ago
- Find new cell phone and tablet pc
3 hours 32 min ago
5 hours 1 min ago
- Automatically updating Guest Additions
6 hours 10 min ago
- I like your topic on android
6 hours 56 min ago
- Reply to comment | Linux Journal
7 hours 17 min ago
- This is the easiest tutorial
13 hours 32 min ago
- Ahh, the Koolaid.
19 hours 10 min ago
- git-annex assistant
1 day 1 hour ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?