Use VNC-[It notes]
Copyright statement: reprinted in the form of hyperlink to indicate the original source and author information and this statement http://shenheng.blogbus.com/logs/10226482.html
First, configure vncserver:
Open the. VNC/xstartup file in the user directory where you want to enable the VNC service. If you want to enable VNC for the root user, run the following command:
Sudo VI/root/. VNC/xstartup
Modify the file content as follows:
#! /Bin/sh # uncomment the following two lines for normal desktop: # unset session_manager # exec/etc/X11/xinit/xinitrc [-x/etc/VNC/xstartup] & exec/etc/VNC/xstartup [-r $ home /. xresources] & xrdb $ home /. xresources xsetroot-solid gray vncconfig-iconic & xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop" & gnome-session # startkde # fvwm2 # TWM &
In the last four lines, select xwindows for VNC connection, gnome-session uses gnome, startkde uses Kde, and so on. However, only one row can be used in the four lines, comment out the remaining three lines.
Edit your/etc/sysconfig/vncservers file, specify the user and the user's desktop, and run the following command to open the file: sudo VI/etc/sysconfig/vncservers
Modify to the following content:
# The vncservers variable is a list of display: User pairs. # uncomment the line below to start a VNC Server on display: 1 # As my 'myusername' (adjust this to your own ). you will also # need to set a VNC password; run 'man vncpasswd' to see how # To Do That. # Do not run this service if your local area network is # untrusted! For a secure way of using VNC, see # <several methods to break the Skynet: how to catch FTP/POP3 plain text, how to close your NetBIOS port, so that hackers cannot intrude into you! Attack tool source code that can disguise IP addresses (for Win2000): several popular intrusion tools and explanations [go] About Win2000 Server Security a multi-function Linux backdoor Source Code cracking system (1-7) port list (from neohapsis) Apche Log Series (1): access log related links a total of 112> ', 'related link') "> URL: http://www.uk.research.att.com/vnc/sshvnc.html>. vncservers = "1: Root" vncserverargs [1] = "-geometry 1024x768"
The default vncserver ports are 6001, 6001, And. Here, "1: Root" indicates that the System user root has enabled ports, and, and 1 indicates the desktop number,
If you need to open ports for multiple users, use the following method: vncservers = "1: Root 2: Xiaowei" the default ports of vncserver are 6001, and. Here "1: Root 2: "Xiaowei" indicates enabling ports 6001, 5901, and 5802 for the System user root, 1 is the desktop number, 5902, 6002, and for the System user Xiaowei, and 2 is the desktop number, and so on.
Also set the logon password vncpasswd
Start vncserver
/Etc/rc. d/init. d/vncserver start
Or
/Etc/init. d/vncserver start
If the following content is displayed, the vncserver is successfully started.
Starting VNC Server: 1: Root [OK]
If your client is Linux, you can use vncviewer for connection. This software should be included in many Linux releases.
For example, if the IP address of the server where the vncserver is located is 192.168.0.1 and the configured desktop number is 1, the connection command is as follows:
Vncviewer 192.168.0.1: 1
Enter the password in the pop-up window.
**************************************** **************************************** *
View the VNC-enabled desktop number and the listening process [root @ Linux/] # netstat-tlnp | grep VNC vncserver command has some useful parameters. Use vncserver -- help. A brief explanation: vncserver [:] [-name] [-geometry X] [-depth] [-pixelformat format] vncserver-kill: Display Number of the VNC service, you can specify it by yourself. Do not use the default value of the system to ensure security. You must enter a correct display number when using a non-zero positive integer vncserver: 99; add the display number to the port number in the browser. The default port is 5800. Enter XXX for remote connection. xxx. xxx. XXX: 5899-name specifies the vncserver desktop name. For example, to display the name as "Red Hat" vncserver-name Red Hat-geometry X, specify the desktop resolution, the default value is 1024x768 vncserver-geometry 800x600. This command is useful in practice. For example, if the local resolution is 1024x768 The resolution of the VNC service may cause incomplete desktop display. -Depth: Specifies the display color. The value ranges from 8 to 8 ~ 32 vncserver-depth 16 is displayed in 16 bits color. The color format specified by pixelformat is roughly the same as that specified by-depth, but the representation method is different. vncserver-pixelformat rgb888 uses the 24bits color to display vncserver-kill: display ends the VNC service and remote desktop vncserver-kill: 1. For more information, see man. The Windows Manager set in VNC is TWM, which may be different from the one you use. You can change the configuration file of VNC to your favorite one by modifying the configuration file as follows: Modify the window manager in the user directory. VNC/xstartup file #! /Bin/sh [-r $ home /. xresources] & xrdb $ home /. xresources xsetroot-solid gray vncconfig-iconic & xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop" & TWM & #! Comment out all the content after/bin/sh and change it ~ /. The xclients file can be saved to test whether the modification is successful. Kill the vncserver service vncserver-kill: or Pa aux | grep xvnc kill PID to restart vncserver, whether to use vncviewer to connect to the Remote Desktop has become your favorite type. In the previous article about VNC server settings (http: // bbs.chinaunix.net/forum/viewtopic.php? T = 368552 & Highlight = yunqing), we can run vncserver on a Linux server for remote access, but note that, if you directly use vncviewer for access, there are two disadvantages: 1. password transmission is in plain text and can be easily listened. 2. the firewall needs to open port 59xx, which is impossible in the general unit. fortunately, we have SSH, a powerful tool, like X11 forwarding. We can use the SSH tunnel to protect the communication process. The following is a brief introduction. assume that the vncserver runs on screen 1 of myserver (IP Address: 192.168.x.x), that is, listening for 192.168.x.x: 5901, and the user name is foo. Scenario 1: The VNC client is Linux, SSH suites are installed by default in general Linux releases. 1. log on to the server using SSH-l 5901: localho St: 5901-l Foo myserver or directly use the IP address ssh-l 5901: localhost: 5901-l Foo 192.168.x.x 2. run vncviewer (or other similar tools) vncviewer localhost on another terminal on the local machine: 1 case 2: The VNC client is Windows 1. download an SSH client. Putty is recommended. Only one program is installed, which is simple and fully functional. download http://www.chiark.greenend.org.uk here /~ Sgtatham/Putty/download.html downloads putty.exe and runs it directly on the desktop. 2. Run putty, enter the IP address of the server, and enter a name. Here, myserver serves as the session name, and press save to save. See Figure 1 3. click tunnels on the left of the dialog box to select related settings, enter 5901 in source port, enter localhost: 5901 in destination, and press add, as shown in Figure 2 4. click Session on the left, return to session settings, and click Save to save the settings. Click Open to log on to the server. 5. run VNC-Viewer (if not, download http://www.realvnc.com/download.html, just use an EXE file) and enter localhost: 1 in the server. See figure 3, after the password is entered, a Linux desktop will appear in windows, which is very secure.
| Using VNC with Linux |
| |
| |
|
Nelson Pereira
I want to use VNC (Virtual Network Computing) in Linux to remote administer my varous machines. 1. introduction1.1 what is VNC?
VNC (Virtual Network Computing) is a remote display system which allows the user to view the desktop of a remote machine anywhere on the Internet. it can be directed through SSH for security. it is a great tool for remote administration and thin clients. it does, however, have its drawbacks. it, unlike tarentella (TM) or Citrix (TM), is not an application server. it also has the tendency to take more time refreshing over low-bandwidth links. 1.2 layout and content of this document
This document is designed to be a quick-start guide to using VNC on Linux RedHat 8.0, but may be the same for Mandrake and/other distro's. the document will cover three basic tolerations in detail. these comprehenations are: Linux desktop on Windows, Windows desktop on Linux, and Linux desktop on Linux. this document will also address the use of SSH to provide a secure VNC connection, allowing multiple users to view (not modify) a Windows desktop, and use VNC on other platforms. this is not designed to be comprehisive. 2. Installing VNC on RedHat 8.0
You shocould get the lates version of VNC server and client from http://www.realvnc.com/download.html. Read the install file stored on the TAR file.
After the tar file is installed there are some additional steps needed to configure VNC to use KDE or GNOME as the desktop. VNC must be configured for each user on the Linux system, I will use the username "John" as the user I will configure VNC for (note: each user has his/her own settings for VNC and also several different incidences of VNC can be run on Linux at the same time, so if you are viewing Linux kernel tops then it cocould work as a thin client server ). the problem is that VNC is somewhat resource intensive (uses about half the resources of a full X Server) so the more VNC instances you run the worse the preformance will be ). first I log in as John and open a terminal window (you can also SSH or telnet to the machine that will be running VNC Server ). I first enter this command:
vncserver
Then I am prompted for the password to connect to the vncserver. the password has to be at least six characters. now the vncserver is running but if you log in you will not have any window manager, so to add this first kill the server using this command:
vncserver -kill :1
If you have more that one vncserver running then replace the 1 with the correct number of the vncserver you want to kill (the number is given when you start the vncserver ).
Now you need to edit ~ /. VNC/xstartup (you can use any text editor to do this). In this file uncomment (remove the # signs) from these lines:
#!/bin/sh[ -r $HOME/.Xresources ]&& xrdb $HOME/.Xresourcesxsetroot -solid greyexec gnome-session &
Now, when you login to VNC as a viewer, a default GNOME session will start.
3. Installing VNC on Windows
VNC for Windows is also available at http://www.realvnc.com/download.html. to install just unzip the VNCwin32-X.X.X.zip file then run setup.exe in the new directory that is created. you will need WinZip or similar utlitiy for windows in order to install it. select the options during setup. 4. Configuration and usage4.1 scenario 1-Linux desktop on a Windows Client
Because Linux is a multi-tasking, multi-user system you can have muliple instances of VNC running. each user on a Linux machine can start a VNC session, and they don't have to worry about stepping on other user's toes. to do this first start the vncserver on Linux by issuing the command:
vncserver -depth 16-geometry 1024x768
You have to start the VNC Server in 16 Bit mode or GNOME will not work. you can use whatever values for geometry you want (800x600 is a good size too ). more bandwidth is required for deeper color depths or larger geometries. after you start the vncserver something similar to this will be returned in terminal:
New 'X' desktop isPC3323:1Starting applicationsspecified in /root/.vnc/xstartupLog file is /root/.vnc/PC3323:1.log
Now, on the Windows machine just double click the vncviewer icon and as the address put the hostname or IP address of the VNC server with a: 1 to specify display #1. if the hostname of the machine is not resolvable then you need to enter the <IPaddress>: 1 to connect to the vncserver. once you enter the correct address for the VNC server and the correct password then you will be presented with a GNOME desktop on your windows desktop. for each new instance of the VNC server, the screen number (: 1 in our example above) will be incremented by one. if I start another vncserver without stopping the first one I started the display number wocould be: 2. to stop the VNC server just issue this command:
vncserver -kill :<screen#>
So to kill the vncserver in our example the command wocould be:
vncserver -kill :1
Only the user who started the VNC server can kill it. It is a good idea to clean up VNC servers for security reasons and to free up system resources. 4.2 scenario 2-making the VNC Server come up at boot
This requires an entry in the/etc/rc. d/RC. local file. you can call the vncserver directly but this will start it as root, which is a bad idea, so we are going to start it as a regular user. the user name we will use for this "user"; just replace all instances of "user" with the username on your machine. basically we just add this line to the end of the RC. local file:
su user -c "vncserver-depth 16 -geometry 1024x768" 4.3 scenario 3-Windows desktop on a Linux Client
Unlike Linux, windows is not a true multi-tasking, multi-user system, so only one instance of the VNC server can run on it. also what ever changes are made from the VNC client are viewedon the local desktop. in other words a user sitting at the Windows machine can watch everything a remote user is doing through VNC, and vice versa.
There are too different configuration setting for the vncserver in windows. I will only cover the basics; For more information see the additional resources section. to start the server just go to the start button-> Programs-> VNC-> RUN WinVNC (APP mode ). this will start a vncserver. when the machine reboots the VNC server will not start automatically. to have the vncserver start automatically go to start-> Programs-> VNC-> Administrative Tools-> install WinVNC service. once the vncserver is running to connect to the server from Linux open a terminal window and type:
vncviewer <ip orhostname > 4.4 scenario 4-allowing multiple users to view the same Windows Desktop
If one client is connected to WinVNC and another user tries to connect the first user will be disconnected. to stop this, You wocould use the-shared option to vncviewer in Linux. for example, if I were viewed a Windows screen along with other clients I wowould type this command:
vncviewer -shared <ip or hostname>
User's can also be prevented from having any control over the windows desktop too. to do this right click on the VNC icon in the system tray, then choose Properties. now check the box "Disable remote keyboard & Pointer" then click OK. 4.5 scenario 5-Linux desktop on Linux
I don't really need to cover this scenario in much detail, but to start the vncserver on one machine just follow the instructions in scenario 1. to start the vncviewer on the client just follow the instructions on in scenario 2. 5. Using SSH for a secure VNC connection
SSH stands for Secure Shell. it uses public key cryptology to enable data sent between two computers. this makes it very hard for anyone to eavesdrop on the communication and steal important information, such as passwords. to use SSH with VNC we are going to setup SSH to listen on a port on the local machine then forward that port through the secure channel to the vncserver. the basic form of the command is this:
ssh -L x:The command works like this: Start an SSH connection to One example applies to connection to a vncserver from Linux Using SSH. using the example from scenario 1, we have a vncserver running on screen: 1 on 134.199, 40.64. lets also add that user 'bob' has started the vncserver, so to setup SSH to forward the ports we wocould run this command on the Linux client: ssh -L5902:134.199.40.64:5901 bob When we hit enter we will be prompted for the password for Bob. the vncserver has to be started prior to running the above comamnd. enter the password and now the connection is up and the port is being forwarded. now to start the vncviewer we use this command in another terminal window on the client machine: vncviewer localhost:2 |
|