RedHat Linux 5.8开启VNC Server远程桌面

注意:防火墙

一、确认及安装VNCSERVER
[root@fox1-101~]# rpm -qa | grep vnc
vnc-server-4.1.2-14.e15_6.6   (表示已经安装)
二、启动VNCSERVER
第一次启动VNCSERVER会提示输入密码,这里分为管理员账户及普通账户,启动方式略有所不同。
1、管理员:
[root@fox1-101~]# vncserver
You will require a password to access your desktops.
Password: 123456            #输入vnc 连接密码
Verify: 123456                 #确认vnc密码
xauth: creating new authority file /root/.Xauthority
New ‘localhost.localdomain:1 (root)’ desktop is localhost.localdomain:1    (表示可用端口1登录了)
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

注意:在这里就可以远程VNC到服务器了,只不过界面是灰色的。
2、普通用户:
[root@fox1-101~]#su djh    (djh是用户名)
[djh@fox1-101~ /]$ vncserver
You will require a password to access your desktops.
Password: 123456            #输入vnc 连接密码
Verify: 123456                 #确认vnc密码
xauth: creating new authority file /home/djh/.Xauthority
New ‘localhost.localdomain:2 (djh)’ desktop is localhost.localdomain:2    (表示可用端口2登录了)
Creating default startup script /home/djh/.vnc/xstartup
Starting applications specified in /home/djh/.vnc/xstartup
Log file is /home/djh/.vnc/localhost.localdomain:2.log
三、相关桌面配置(解决灰色画面问题)。RedHat Linux支持两种图形模式:KDE模式和gnome模式。
1、修改用户的的VNC配置文件
你的RedHalt使用的什么图形模式这个一般只有登录到图形界面查看一下才能知道,或者通过ps -A命令列出所有当前运行的程序,看看有没有KDE或者gnome字样来判断一下。如果你是gnome桌面,那么你需要修改/root/.vnc/xstartup的配置文件。
[root@fox1-101~]# vi /root/.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 &

2、重启vncserver服务
[root@fox1-101~]# /sbin/service vncserver start/stop/restart     (因为是以su切换到root用户,但实际并不是在服务器上用root登录一样。所以这里需要加上/sbin/service,否则报无service文件。)

设置修改完毕最好是重启一次系统,否则设置不会生效。我采用的方法是杀死VNCSERVER进程再重运行VNCSERVER。

[[root@fox1-101~]# vncserver -kill :1      #这里你启动vncserver时是什么端口号要对应上。
[root@fox1-101~]# vncserver  :1            #重启VNCSERVER,注意:1前面一定要有空格。

注意:可以用vncpasswd修改VNC的登录密码;

3、设置用户信息及分辨率。

 

注意:想重启动后自动运行VNCServer,其实现方法如下修改配置文件,取消这2行前的#号即可。

VNCSERVERS="1:root"           
VNCSERVERARGS[2]="-geometry 800×600 -nolisten tcp -nohttpd -localhost"    //这里修改成2才能用(下次不取消这个注释看看。)

 

[root@localhost: ~]#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="1:root 2:djh"            #此处添加用户,一般只添加一个1:root也就行了。
VNCSERVERARGS[1]="-geometry 800×600 -nolisten tcp -nohttpd -localhost"
VNCSERVERARGS[2]="-geometry 1024×768 -nolisten tcp -nohttpd -localhost"

#注意:上面是分别设置的root和djh两个用户的分辨率,注意是用端口号区分的。

另外也可以通过命令行临时修改分辨率及色深,这种方式重启后就会丢失,这里暂时用不到,命令如下:
[root@localhost: ~]#vncserver -geometry 800×600        #设置vncserver的分辨率   
[root@localhost: ~]#vncserver -depth 16           #设置vncserver的色深
到这里VNCSERVER服务器端就配置完成了。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值