欢迎各位兄弟 发布技术文章
这里的技术是共享的
VNC: 虚拟网络计算 virtual network Computing
一种明文协议;数据传输,认证过程都是有可能明文的,所以跨互联网使用VNC不安全
能够实现跨平台共享桌面的
既可以基于客户端来实现,又可以基于浏览器来实现,功能很强大
linux 没有开启图形界面,但是能让 其它 windows 或 linux 远程打开它的桌面
使用 VNC Viewer
linux 上要安装 VNC Server
[root@mail scripts]# rpm -qa vnc* #已安装了 vnc server
vnc-server-4.1.2-14.el5_6.6
[root@mail scripts]#
远程连接 vnc 也需要输入用户名( 比如 root)
,但是密码与登录系统时密码不一样(不是 /etc/shadow),独立存储,加密的;(但传输过程未必加密)
vncpasswd 设置当前用户的vnc访问密码
[root@mail scripts]# vncpasswd
Password:
Verify:
[root@mail scripts]#
#启动vnc服务
[root@mail scripts]# service vncserver start # 这里未执行,第一次使用时不建议使用这个命令
[root@mail scripts]# vncserver & # 第一次使用这个命令来启动服务, 与符号 & 表示在后台运行
[1] 27063
[root@mail scripts]# xauth: creating new authority file /root/.Xauthority
New 'mail.magedu.com:1 (root)' desktop is mail.magedu.com:1 # 冒号 1 类似于 screen 可以有多个桌面 冒号1表示第一个
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/mail.magedu.com:1.log # 这个按个ctrl+c
[1]+ Done vncserver
[root@mail scripts]# vncserver & # 再启动一次
[1] 27110
[root@mail scripts]#
New 'mail.magedu.com:2 (root)' desktop is mail.magedu.com:2 #冒号2 这是第二个屏幕
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/mail.magedu.com:2.log
我在 360 安全卫士上安装一个 Vnc Viewer
如下图 ip:1 表示连接第一个屏幕
也可以连第二个屏幕
上面的几个图 叫 twm : 窗口管理器
wm (windows manager )
twm 是窗口管理器中著名的一种
要配置使用 gnome 桌面了
[root@mail ~]# pwd
/root
[root@mail ~]# ls -la # 在当前用户的家目录下,会看到 .vnc
.vnc
[root@mail ~]# cd .vnc
[root@mail .vnc]# pwd
/root/.vnc
[root@mail .vnc]# ls
mail.magedu.com:1.log mail.magedu.com:2.log passwd
mail.magedu.com:1.pid mail.magedu.com:2.pid xstartup
[root@mail .vnc]#
[root@mail .vnc]# vim 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" &
gnome-session & # 这里把 twm & 改成 gnome-session &
[root@mail .vnc]# cd
[root@mail ~]# pwd
/root
[root@mail ~]# service vncserver restart # 这一个命令未执行;;重启 vncserver 这个命令不太好用
先杀死两个屏幕
[root@mail ~]# vncserver -kill :2
Killing Xvnc process ID 27118
[root@mail ~]# vncserver -kill :1
Killing Xvnc process ID 27071
[root@mail ~]#
[root@mail ~]# service vncserver start # 启动 vnc服务器
启动 VNC 服务器:no displays configured [确定]
[root@mail ~]#
客户端 此时连不上 ;;所以 service vncserver start 仍然不能用
# 仍然使用 vncserver 命令启动服务
[root@mail ~]# vncserver &
[1] 27215
[root@mail ~]#
New 'mail.magedu.com:1 (root)' desktop is mail.magedu.com:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/mail.magedu.com:1.log
此时客户端连上了 vncserver
每次开机 都能自动启动
[root@mail ~]# chkconfig vncserver on
[root@mail ~]#