vnc远程控制linux密码,使用VNC实现LINUX与windows的相互远程控制

1、确认linux系统是否安装VNC

默认情况下,Red Hat Enterprise Linux安装程序会将VNC服务安装在系统上。

[root@localhost ~]# rpm -qa|grep vnc

vnc-server-4.1.2-9.el5

[root@localhost ~]#

2、[root@localhost ~]# service vncserver start 第一次启动时会提示输入密码,这个密码是客户端登录这个VNC服务器时需要提供的验证密码。

vncserver服务启动后会在当前用户的宿主目录中生成.vnc目录,如下所示:

[root@localhost ~]# ls -a

.                .cshrc    .gnome2             .metacity   .vnc..               Desktop   .gnome2_private     .mozilla    .Xauthority

anaconda-ks.cfg  .dmrc     .gstreamer-0.10     .nautilus   .xsession-errors

.bash_history    .eggcups  .gtkrc-1.2-gnome2   .redhat

.bash_logout     .gconf    .ICEauthority       .tcshrc

.bash_profile    .gconfd   install.log         .Trash

.bashrc          .gnome    install.log.syslog  .twmjtHtnR

[root@localhost ~]#

[root@localhost .vnc]# ls

localhost.localdomain:1.log  localhost.localdomain:1.pid  passwd  xstartup

[root@localhost .vnc]#

因为服务是第一次执行,需要输入密码,这个密码被加密保存在用户主目录下的.vnc子目录(/root/.vnc/passwd)中;同时在用户主目录下的.vnc子目录中为用户自动建立xstartup配置文件(/root/.vnc/xstartup),在每次启动VND服务时,都会读取该文件中的配置信息。:/root/.vnc/目录下还有一个“testdb:1.pid”文件,这个文件记录着启动VNC后对应后天操作系统的进程号,用于停止VNC服务时准确定位进程号。

3.VNC服务使用的端口号与桌面号的关系

VNC服务使用的端口号与桌面号相关,VNC使用TCP端口从5900开始,对应关系如下

桌面号为“1”  ---- 端口号为5901

桌面号为“2”  ---- 端口号为5902

桌面号为“3”  ---- 端口号为5903

……

基于Java的VNC客户程序Web服务TCP端口从5800开始,也是与桌面号相关,对应关系如下

桌面号为“1”  ---- 端口号为5801

桌面号为“2”  ---- 端口号为5802

桌面号为“3”  ---- 端口号为5803

4、要想登录后linux的图形界面,需要修改配置文件:

[root@testdb ~]# 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 &

5:重新启动vncserver服务的方法:

[root@testdb ~]# vncserver -kill :1

[root@testdb ~]# vncserver :1

在IP为192.168.1.234的linux主机中配置VNC服务器:

[root@localhost ~]# rpm -qa|grep vnc

vnc-server-4.1.2-9.el5

[root@localhost ~]# vncserver :1

You will require a password to access your desktops.

Password:

Verify:                         这个密码可以通过vncpasswd来修改

xauth:  creating new authority file /root/.Xauthority

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

[root@localhost ~]# ls -a

.                .bashrc   .gconfd            .ICEauthority       .tcshrc

..               .cshrc    .gnome             install.log         .Trash

anaconda-ks.cfg  Desktop   .gnome2            install.log.syslog  .vnc

.bash_history    .dmrc     .gnome2_private    .metacity           .Xauthority

.bash_logout     .eggcups  .gstreamer-0.10    .nautilus           .xsession-errors

.bash_profile    .gconf    .gtkrc-1.2-gnome2  .redhat

[root@localhost ~]# cd .vnc/

[root@localhost .vnc]# ls

localhost.localdomain:1.log  localhost.localdomain:1.pid  passwd  xstartup

[root@localhost .vnc]# ll

total 16

-rw-r--r-- 1 root root 556 May 19 10:28 localhost.localdomain:1.log

-rw-r--r-- 1 root root   5 May 19 10:28 localhost.localdomain:1.pid

-rw------- 1 root root   8 May 19 10:28 passwd

-rwxr-xr-x 1 root root 334 May 19 10:28 xstartup

[root@localhost .vnc]#

[root@localhost .vnc]# netstat -ntpl|grep vnc

tcp        0      0 0.0.0.0:5801                0.0.0.0:*                   LISTEN      3480/Xvnc

tcp        0      0 0.0.0.0:5901                0.0.0.0:*                   LISTEN      3480/Xvnc

tcp        0      0 0.0.0.0:6001                0.0.0.0:*                   LISTEN      3480/Xvnc

tcp        0      0 :::6001                     :::*                        LISTEN      3480/Xvnc

别忘了把防火墙关闭。

在windows主机上安装VNC客户端:

安装企业版VNC(含有服务器端和客户端)

这个时候就可以使用客户端vnc viewer远程linux的VNC服务器了,现在只能使用linux的字符界面。注意访问的是:192.168.1.234:1

如果想用图形界面,还需要修改一个配置文件:

[root@localhost .vnc]# vi 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

[root@localhost .vnc]# vncserver -kill :1

Killing Xvnc process ID 3480

[root@localhost .vnc]# vncserver :1

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/localhost.localdomain:1.log

[root@localhost .vnc]#

这时再使用xp上的vnc viewer就可以远程linux图形界面了。

第二种方法是使用Web浏览器(如Firefox,IE,Safari)登陆测试,操作流程如下地址栏输入 --> 出现VNC viewer for Java(此工具是使用Java编写的VNC客户端程序)界面,同时跳出VNC viewer对话框,在Server处输入“192.168.1.234:1”点击“OK” --> Password输入登陆密码 --> 点击“OK”登陆到X-Window图形桌面环境 --> 测试成功

(注:VNC viewer for Java需要JRE支持,如果页面无法显示,表示没有安装JRE,可以到下载最新的JRE,然后在客户机上进行安装)。

#vi  /etc/sysconfig/vncservers,以下是文件内容:

# The VNCSERVERS variable is a list of display:user pairs.

#

# Uncomment the line below to start a VNC server on display : 1

# 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

# .

VNCSERVERS

= “ 1:user1 2:user2 3:user3 “

VNCSERVERARGS [ 1 ] = “ -geometry 1024×768 “

VNCSERVERARGS [ 2 ] = “ -geometry 1024×768 “

VNCSERVERARGS [ 3 ] = “ -geometry 800×600 “

解释一下这个文件:

VNCSERVERS这一行是配置在系统启动时启动几个VNC server,上面的例子里运行了三个VNC server,其中user1在display :1,user2在display :2,user3在display :3。

VNCSERVERARGS这三行,分别为VNC server 1, 2, 3配置启动参数,上面的例子里对user1和user2使用屏幕分辨率1024×768,对user3使用800×600

其它支持的参数请使用“man vncserver”命令查询。

编辑好这个文件后,保存,然后以root身份运行:

/sbin/service vncserver start

这样user1, user2, user3的vncserver就启动了。

以后每次系统重启时,都会自动启动这三个用户的vncserver。

注意:上面三个用户必须已经使用vncpasswd命令设置过vnc密码,不然他的vncserver启动会失败!

[root@localhost ~]# service vncserver restart

Shutting down VNC server: 1:root 2:lisi 3:tom              [  OK  ]

Starting VNC server: 1:root

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/localhost.localdomain:1.log

2:lisi

New 'localhost.localdomain:2 (lisi)' desktop is localhost.localdomain:2

Starting applications specified in /home/lisi/.vnc/xstartup

Log file is /home/lisi/.vnc/localhost.localdomain:2.log

3:tom

New 'localhost.localdomain:3 (tom)' desktop is localhost.localdomain:3

Starting applications specified in /home/tom/.vnc/xstartup

Log file is /home/tom/.vnc/localhost.localdomain:3.log

[  OK  ]

[root@localhost ~]#

使用VNC View远程访问Linux,总是没有办法切换出SCIM输入法,研究了很久,终于让我找到了解决 方法 。

1)修改.vnc/xstartup文件,在最后一行加入:scim -d,意思为打开SCIM输入法

2)使用VNC View访问Linux系统以后,修改scim输入法的快捷键,因为默认打开输入法的快捷键为ctrl space,与本地机器上切换输入法的快捷键冲 突,系统 会先接收到本地的命令,所以没办法使用默认快捷键打开输入法。将打开SCIM输入法的快捷键修改为Ctrl Alt Space。

在windows上安装vnc服务器,使用vnc4.0.rar这个软件,最好不要使用企业版的。安装时可以设置一个远程时的验证密码,安装好后使用linux下的vnc viewer远程就可以了,只需要输入windows的IP就可以了,不

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值