码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下配置VNC

时间:2017-05-17 14:04:14      阅读:308      评论:0      收藏:0      [点我收藏+]

标签:manage   不能   table   pair   port   enter   防火墙   listen   starting   

环境: REDHAT 5


1. 检查是否安装了VNC:
rpm -qa vnc-server

vnc-server-4.1.2-9.el5


没安装的话。安装一下:
yum install vnc-server


2. 配置vncserver登录password:
[root@Redhat ~]# vncserver


You will require a password to access your desktops.


Password:
Verify:
xauth:  creating new authority file /root/.Xauthority

New ‘Redhat:1 (root)‘ desktop is Redhat:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Redhat:1.log


3. 配置vncserver启动文件:
vi ~/.vnc/xstartup

改动后文件:


#!/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 grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
# twm &
gnome-session &


4. 配置vncservers文件
vi /etc/sysconfig/vncservers
改动后文件:
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# 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
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-nohttpd" to prevent web-based VNC clients connecting.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer‘ manual page.
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd -localhost"


5. 关闭防火墙
service iptables stop
或者开放VNCport:
/sbin/iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 5900:5903 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart


6. 杀掉当前进程:
vncserver -kill :1
vncserver -kill :2 
...

7. 启动vncserver
[root@Redhat ~]# vncserver

New ‘Redhat:1 (root)‘ desktop is Redhat:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Redhat:1.log



8. 通过浏览器(JAVA)连接:
http://192.168.65.131:5801/

技术分享



9. 通过VNC Viewerclient连接:
192.168.65.131:1
技术分享

依据提示输入前面配置的登录password就可以打开!

技术分享


PS:可能出现的问题:


a、黑屏
在Linux里安装配置完VNC服务端,发现多用户登陆会出现黑屏的情况,详细的现象为:
client能够通过IP与会话号登陆进入系统,但登陆进去是漆黑一片。除了一个叉形的鼠标以外,伸手不见五指。


原因:用户的VNC的启动文件权限未设置正确。


解决方法:将黑屏用户的xstartup(一般为:/home/username称/.vnc/xstartup)文件的属性改动为755(rwxr-xr-x)。




b、vnc 能输入数字,但不能输入字母
原因:vnc server这边会要求vnc viewer这边OS的输入法要和vnc server那边OS的语言要一致。


解决方法:一般我们装的Linux OS都是E文的,所以使用vnc viewer连入的时候,请关闭本地OS的中文输入法。切换到英语就能够了。


--------------------------------

Dylan    Presents.



Linux下配置VNC

标签:manage   不能   table   pair   port   enter   防火墙   listen   starting   

原文地址:http://www.cnblogs.com/liguangsunls/p/6866901.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!