centos下远程桌面的设置及问题处理



这几天在研究linux下远程,现把这些资料记录如下,资料是网络上找来的 
 
1.检查VNC客户端和服务器端是否已经安装 
 
执行如下命令: 
rpm -q vnc vnc-server 
假如返回类似如下信息, 
[root@localhost likeshare]# rpm -q vnc vnc-server 
vnc-4.1.2-14.el5_6.6 
vnc-server-4.1.2-14.el5_6.6 
则说明系统已经默认安装了vnc服务器端(一般来说,CentOS系统都默认安装了vnc server)。 
 
如果没有安装vnc-server 
 
可以按如下方式在线安装 
 
yum  install vnc vnc-server 
 
确定vnc-server已经安装 
 
启动vncserver 
[root@localhost likeshare]# vncserver 
 
New 'localhost:4 (likeshare)' desktop is localhost:4 
 
Starting applications specified in /root/.vnc/xstartup 
Log file is /root/.vnc/localhost:4.log   www.2cto.com 
2. 修改VNC SERVER的窗口治理器 
上面的启动过程显示vnc的配置文件和日志文件存放在.vnc/这个文件下 
 
编辑xstartup文件,使窗口管理器更好看 
 
因为默认的是twn有点愁 
 
[root@localhost likeshare]# 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& #加上这行 
 
#startkde #kde desktop #如果是用kde去掉这行前面的注释号即可 
如果有其他的用户依次照照做就可以 
3 在CentOS系统中将用户名加入到配置文件中 
使用如下命令编辑配置文件,添加帐户信息: 
vi /etc/sysconfig/vncservers 
做如下修改 
#  
# 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.    www.2cto.com 
#  
# DO NOT RUN THIS SERVICE if your local area network is  
# untrusted! For a secure way of using VNC, see  
# lt;URL:http://www.uk.research.att.com/vnc/sshvnc.htmlamp;gt;.  
# VNCSERVERS="1:myusername" 
# VNCSERVERS="1:gavin 2:john" # use the method for more user  
VNCSERVERS="2:root" 
# VNCSERVERARGS[1]="-geometry 800x600"  
VNCSERVERARGS[2]="-geometry 1024x768"  
这是我自己的配置文件 
 
#VNCSERVERS="1: user1 2: user2 3: user3" 
VNCSERVERS="2:root" 
#VNCSERVERS=[2]="-geometry" 
 
#VNCSERVERS=[3]="-geometry 1024x768" 
 
VNCSERVERARGS[2]="-geometry 800x600" 
#VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" 
#VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" 
在这里有点不明白的是,我设置的登录用户是root 
但是我用likeshare也是可以登录的 
 
不知道什么原因,有时间测试下, 
 
退出vi 按esc 然后:wq回车 
 
启动vncserver 
 
3.启动VNC服务 
 
使用如下命令启动VNC SERVER 
sbin/service vncserver start 
当显示如下信息时,表示启动成功: 
Starting VNC server: 2:root  [ OK ] 
 
启动失败有这么几个援引我自己遇到的。 
1。配置文件有问题,像参数给的不正确,格式写的有问题 
 
我就是因为VNCSERVERARGS[2]="-geometry 800x600"分辨率的x有问题的所以服务启动出问题 
多试试搞定 
 
4、从VNC view登录 
 
在windows上安装vnc view,然后输入xxx.xxx.xxx.xxx:2,连接登录,输入密码即可。备注:假如从vnc view登录时,提示connection refused(10061),则是因为linux防火墙的问题,登录centos系统,选择SystemPreferencesRemote Desktop,勾选sharing中的两项,Security两项不勾,点击关闭,然后再重新用vnc view登录即可   www.2cto.com 
也可以用命令来设置防火墙如下: 
vi /etc/sysconfig/iptables 
找到以下的语句: 
 
-A RH-Firewall-l-INPUT-j INPUT-j REJECT - reject-with icmp-host-prohibited 
 
在此语句前面加上下面的内容: 
 
-A Rh-Firewall-l-INPUT-m state -state NEW-m tcp-p tcp-dport 5900 -j ACCEPT
 

 
 
 
作者 lt200819

相关内容

    暂无相关文章