Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1124808
  • 博文数量: 188
  • 博客积分: 2267
  • 博客等级: 大尉
  • 技术积分: 1907
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-01 11:17
文章分类

全部博文(188)

文章存档

2016年(16)

2015年(16)

2014年(12)

2013年(32)

2012年(45)

2011年(67)

分类: LINUX

2011-08-17 12:19:41

VNC基本上是属于一种显示系统,也就是说他能将完整的窗口界面通过网络,传输到另一台计算机的屏幕上。

环境:Server,Client, RHEL6

首先需要安装 vnc-server ,vnc

1.配置一下vnc-server 端

#yum install vnc-server -y

2.第一次需要设置一下server 的 password

[root@desktop19 Desktop]#vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'desktop19.example.com:1 (root)' desktop is desktop19.example.com:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/desktop19.example.com:1.log
3.需要重启一下服务,直接把开的这个1端口干掉,然后允许vncserver 即可!

[root@desktop19 Desktop]#vncserver -kill :1
Killing Xvnc process ID 3128
[root@desktop19 Desktop]#vncserver

New 'desktop19.example.com:1 (root)' desktop is desktop19.example.com:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/desktop19.example.com:1.log

ps: (在rhel6之前,需要更改用户主目录下[root@desktop19 ~]# vim .vnc/xstartup 

   把第3,4 行的unset前的# 去掉,把最后一行的 twm 改成 gnome-session )

4.在client测试一下,输入:vncviewer -shared -viewonly 192.168.0.19:1

 其中 shared 表示共享连接,不会把别人T掉,viewonly 表示只读,如果想操作的话,就不用加这个参数了!

 

如果我们想做一些限制的话,可以在

[root@desktop19 ~]#vim /etc/sysconfig/vncservers

1.允许不同用户vnc链接上来操作,互不影响

可以在此文件的最后一行加上VNCSERVERS=“1:frank 2:rambo”(最好是顶格写)

这样还是不行的,还需用在frank ,rambo 的用户主目录下执行vncserver ,为他们设置密码,以及初始化文件,否则重启服务会出错滴(这个密码可以使用vncpasswd 更改的)

[root@desktop19 ~]#su - frank
[frank@desktop19 ~]$vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'desktop19.example.com:1 (frank)' desktop is desktop19.example.com:1

Starting applications specified in /home/frank/.vnc/xstartup
Log file is /home/frank/.vnc/desktop19.example.com:1.log

[frank@desktop19 ~]$ logout
[root@desktop19 ~]#su - rambo
[rambo@desktop19 ~]$vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth:  creating new authority file /home/rambo/.Xauthority

New 'desktop19.example.com:2 (rambo)' desktop is desktop19.example.com:2

Creating default startup script /home/rambo/.vnc/xstartup
Starting applications specified in /home/rambo/.vnc/xstartup
Log file is /home/rambo/.vnc/desktop19.example.com:2.log

 

ok,现在我们重启一下服务,可能时间会稍微长一点哦

[root@desktop19 ~]#/etc/init.d/vncserver restart
Shutting down VNC server: 1:frank 2:rambo                  [  OK  ]
Starting VNC server: 1:frank xauth:  timeout in locking authority file /var/run/gdm/auth-for-root-fcRq7K/database

New 'desktop19.example.com:1 (frank)' desktop is desktop19.example.com:1

Starting applications specified in /home/frank/.vnc/xstartup
Log file is /home/frank/.vnc/desktop19.example.com:1.log

2:rambo xauth:  timeout in locking authority file /var/run/gdm/auth-for-root-fcRq7K/database

New 'desktop19.example.com:2 (rambo)' desktop is desktop19.example.com:2

Starting applications specified in /home/rambo/.vnc/xstartup
Log file is /home/rambo/.vnc/desktop19.example.com:2.log

                                                           [  OK  ]



5.可以在远端client 进行访问了,vncviewer -shared 192.168.0.19:X (1连上去就是frank,2连上去就是rambo)

6.我们有时候也可以根据自己显示器的大小来调成vnc链接上去的大小,比如你的分辨率是1024x768 ,服务器默认是1680x1050,你就会用的很不爽啊,这时候我们就可以在刚才这个配置文件来加一行

重启一下服务看看咯!可以比较一下哦,链接上去在右上角可以看到你以什么身份登录上去滴


 

PS:扩展一下把,这里只是为了方便,出现任何安全为题,本人概不负责!


在链接vnc的时候每次都要敲这么长一串是不是很繁琐啊,这样的话,我们可以在/usr/local/bin 下新建一个vnc,在里边写上vncviewer -shared -viewonly -192.168.0.19:1 -paasswd /usr/local/bin/vncpasswd &

然后chmod +x vnc ,给这个文件一个可执行权限,前提是得有这个 /usr/local/bin/vncpasswd 这个文件怎么来呢,可以用vncserver 生成一个,默认是passwd ,我改成了 vncpasswd (因为哥上次把passwd 直接放在哪个目录了,最后把系统的passwd覆盖了,后果…………),chmod 777 vncpasswd就可,然后每次在Terminal 下敲vnc 就出来了,密码都不用输入,是不是很方便啊,如果你vnc 都懒得敲,那哥在告诉你个绝招,设置快捷键把,system-preferences-keyboard shortcuts-Add

写上你的路径,然后设置快捷键咯,点到vnc上边,然后按你比较习惯的快捷键把!

阅读(1726) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~