linux 6.5 安装vnc,CentOS 6.5 安装VNC

CentOS 6.5 安装VNC

在Linux下用VNC远程桌面是个很不错的玩意。但在CentOS中默认没有安装VNC的。可以用下面语句查询,如果出现下面情况说明没有安装vnc

一、检查桌面程序是否已安装

#rpm -q “X Window System” “Desktop” “Chinese Support”

#yum groupinstall -y "X Window System" "Desktop" "Chinese Support"

二、检查vnc相关服务是否安装

#rpm -q tigervnc tigervnc-server  vnc vnc-server

package tigervnc is not installed

package tigervnc-server is not installed

1、安装VNC服务

#yum install tigervnc tigervnc-server  vnc vnc-server

然后就等待安装完成。

2、为vncserver设置周密码

[root@www.linuxidc.com ~]# vncserver  或者vncpasswd

You will require a password to access your desktops.

Password:

Verify:

启动服务:#service vncserver restart

注:如果出现FAILED那一般是配置文件写错了,如果检查后问题依旧,并且错误提示与下图类似那么则是版本原因。安装或更新x11.

命令:yum install pixman pixman-devel libXfont -y

请注意libXfont 里面的X是大写的哦。

3、 配置VNC

为了防黑屏,需要修改一下/root/.vnc/xstartup。

注释下面两行

#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

#twm &

然后再添加下面一行

gnome-session &

[root@GUOKE ~]# vi /root/.vnc/xstartup

#!/bin/sh

[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n

export LANG

export SYSFONT

vncconfig -iconic &

unset SESSION_MANAGER

unset DBUS_SESSION_BUS_ADDRESS

OS=`uname -s`

if [ $OS = 'Linux' ]; then

case "$WINDOWMANAGER" in

*gnome*)

if [ -e /etc/SuSE-release ]; then

PATH=$PATH:/opt/gnome/bin

export PATH

fi

;;

esac

fi

if [ -x /etc/X11/xinit/xinitrc ]; then

exec /etc/X11/xinit/xinitrc

fi

if [ -f /etc/X11/xinit/xinitrc ]; then

exec sh /etc/X11/xinit/xinitrc

fi

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

#twm &

gnome-session &

修改用户配置文件:/etc/sysconfig/vncservers

去掉下面这两行前的“#”,也就是说把这两行的注释给去掉。

VNCSERVERS="2:root"

VNCSERVERARGS[2]="-geometry 1024x768 -depth 32"

改完后的配置文件如下

[root@GUOKE ~]# 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 this URL:

# http://kbase.redhat.com/faq/docs/DOC-7028

# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.

# 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:root"

VNCSERVERARGS[2]="-geometry 1024x768 -depth 32"

4、改变xstartup的权限

chmod 777 /root/.vnc/xstartup

5、防火墙开端口,netstat -antpl查看可以发现有三个端口在监听。

5901 5801 6001

这三个端口:

默认的, vnc 服务监听3个TCP端口

RFB(Remote FrameBuffer)协议 默认端口 : 5900 显示器号

HTTP协议默认端口 : 5800 显示器号

X协议 默认端口 : 6000 显示器号

vncserver使用的显示器编号默认从1开始, 依次使用, 也可以参数指定端口号

我们只需要RFB协议就好了,所以,我们在防火墙中加5900到5903这几个,这样就可以开3个了。

vi /etc/sysconfig/iptables 找到下面的语句:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

在这之后填加:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT

重起防火墙

service iptables restart

6、起动vnc服务器

/etc/init.d/vncserver start

然后在windows中用vnc客户端登录

BBCC8C2ED9264623AF57CBC9E4701A62

7FCC60F99D4F41FBAE9221ED51BEAFBA

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值