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

Linux实现vnc管理

2013-08-03 10:47 218 查看
VNC (Virtual Network Computing)是虚拟网络计算机的缩写。VNC 是一款优秀的远程控制工具软件,由著名的 AT&T 的欧洲研究实验室开发的。VNC 是在基于 UNIXLinux操作系统的免费的开源软件远程控制能力强大,高效实用,其性能可以和 WindowsMAC 中的任何远程控制软件媲美。 在 Linux 中,VNC 包括以下四个命令:vncserver,vncviewer,vncpasswd,和 vncconnect。大多数情况下我只需要其中的两个命令:vncserver 和 vncviewer,使用vnc是图形化。对于刚接触Linux的朋友说是做好的解决方案,在安装前下安装centos桌面
yum install -y vnc vnc-server 一般vnc的软件包,系统在安装的时候默认已经安装
useradd admin
vncpasswd 设置vnc服务器端,访问密码
Password:
Verify:
ls .vnc/

passwd
vim /etc/sysconfig/vncservers 编辑vnc配置文件,红笔为需要修改的部分
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:admin" 如果有多个用户可以写多行
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
vncserver 启动服务

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
netstat -tuplna | grep vnc

tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN 3870/Xvnc
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 3870/Xvnc
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 3870/Xvnc
tcp 0 0 :::6001 :::* LISTEN 3870/Xvnc
下面设置客户端



此软件可以在百度找到,主意安装的时候安装客户端



输入 服务器ip:端口号 默认为5901



输入vncpasswd,设置的密码







到此只能证明成功了一半,需要设置桌面的参数
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 & 写入一下代码,个人习惯是先备份在删除从新写入
vncserver -kill :1 如果vnc开启进程是挂起的,需要结束
vncserver :1 开启vnc进程



重新登入测试



输入密码



如果看到这个界面证明vnc配置正确,就可以使用图形化来管理linux了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux实现vnc管理