您的位置:首页 > 运维架构 > Linux

centOS6.2 VNCserver搭建

2012-09-21 10:53 120 查看
任务:使工作的windowPC连接远程linux服务器桌面
使用环境:centos6.2 x64 yum可用
一、安装VNCserver端
# yum install tigervnc-server
二、配置服务
如果使用root用户执行,则生成root用户的vnc配置
[root@so366]# vncserver
xauth: creating new authority file /root/.Xauthority
xauth: (stdin):1: bad display name "so366:1" in "add" command

New 'so366:1 (root)' desktop is so366:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/so366:1.log
会在当前用户主目录下 生成 .vnc 目录和配置文件
设置客户端登录密码
[root@so366]# vncpasswd
Password:
Verify:
设置的密码保存在 /root/.vnc/passwd
修改配置文件:
修改 xstartup 文件 把最后一行的 twm & 删掉 加上 gnome-session &
[root@so366 ~]# sed -i 's/twm &/gnome-session &/' ~/.vnc/xstartup
查看修改效果
[root@so366 ~]# tail -n 3 ~/.vnc/xstartup
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session twm &

修改vncserver的配置
# 桌面号:用户 监听 590* 端口
[root@so366 ~]# echo 'VNCSERVERS="2:root"' >> /etc/sysconfig/vncservers
[root@so366 ~]# echo 'VNCSERVERARGS[2]="-geometry 800x600"' >> /etc/sysconfig/vncservers
这样修改后,就算 /etc/inittab 启动模式为 3 也可以正常进入图形界面

[root@so366 ~]# /etc/init.d/vncserver start
正在启动 VNC 服务器:2:root xauth: (stdin):1: bad display name "so366:2" in "add" command

New 'so366:2 (root)' desktop is so366:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/so366:2.log

[确定]
现在就可以在window下使用客户端工具登录系统了
推荐使用:RealVNC
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息