vnc配置流程及配置过程中出现的问题解决方案

本文详述了VNC服务器的配置过程,包括安装、设置密码、启动服务、修改窗口管理器、防火墙端口开放及解决VNC黑屏问题。通过设置 VNCSERVERS 和 VNCSERVERARGS,确保多个用户可以接入,并调整窗口分辨率。同时介绍了如何在iptables中允许VNC端口,以及应对远程桌面黑屏的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                          vnc安装记录
[root@AA/]# rpm -qa|grep vnc(检查是否安装vnc,红帽里已自带)
下面是安装时的源程序:

一、vim /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"

用下面的源程序覆盖上面的就OK了,用网上提供给的,会出错的,我TEST。

#

# 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

# URL:http://www.uk.research.att.com/vnc/sshvnc.html>.


# VNCSERVERS="1:myusername"


# VNCSERVERS="1:mes 2:xiaofu" # use the method for more user

VNCSERVERS="1:root 2:oracle 3:fish"(这是要添加的)


# VNCSERVERARGS[1]="-geometry 800x600"

VNCSERVERARGS[1]="-geometry 1024x768"(这是要添加的)
VNCSERVERARGS[2]="-geometry 1024x768"
VNCSERVERARGS[3]="-geometry 1024x768"
二、设置 root用户的密码,使用如下命令设置密码:vncpasswd,当提示Verify时,再次输入密码确认。

三、启动VNC服务,service vncserver start 。
四、修改VNC SERVER的窗口管理器
vnc server默认使用的窗口管理器是twn,这是一个非常简单的窗口管理器,我们可以改成常用的GNOME或者KDE。
即vim xstartup   #twm & #注掉系统默认的窗口管理器    添加这样一句:gnome-session &     #以GNOME作为VNC的窗口管理器
五、重启VNC SERVER
    重启VNC服务,service vncserver restart
六、关键的,在防火墙里打开端口,就可以使用VNC Viewer了。
用 root 操作           vim /etc/sysconfig/iptables
vim /etc/sysconfig/iptables 找到下面的语句:

-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited

在此行之前,加上下面的内容:

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5901:5903 -j ACCEPT            即 5901 为默认桌面 1 的端口号,5902 为默认桌面 2 的端口号,5903为默认桌面 3的端口号   
 然后使用root身份重新启动防火墙:
[root@localhost~]#/sbin/service iptables restart
七、设置成后台服务

管理---服务器设置---服务---vncserver ---打勾---保存
在客户端上下载一个vncviewer,打开vncviewer.exe,输入服务器的IP:端口号(10.25.3.74:1),密码即可。

 Linux VNC黑屏情况出现,解决如下:

如果远程Linux的VNC桌面很久没有输入,那么使用VNC View打开远程linux桌面时,桌面显示不出来,显示一片黑屏,并且点击键盘或者鼠标仍然毫无反应,仍然一片黑屏。
这时候需要在vnc server上设置一下。
编辑 /root/.vnc/xstartup

[root@localhost ~]# vim /root/.vnc/xstartup   


去掉下面两行的注释:

unset SESSION_MANAGER  
exec /etc/X11/xinit/xinitrc  

执行下面的命令重启vnc server:

[root@localhost ~]# vncserver -kill :1  
[root@localhost ~]# vncserver :1



  执行命令

  # /etc/init.d/vncserver start/stop/restart

  或

  # service vncserver start/stop/restart



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值