当前位置: 首页 > article >正文

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就可以了,不

http://www.lryc.cn/news/2420508.html

相关文章:

  • 《WinForm开发系列之控件篇》Item2 BindingNavigator
  • 会声会影x4素材_会声会影2020旗舰版Corel VideoStudio Ultimate 2020中文版
  • hadoop集群搭建(一)(超详细)
  • 网络爬虫:爬取网页数据
  • 一文全面讲清操作系统,附各类操作系统(windows、macOS 、ChromeOS等应知应会)
  • xcode 升级到4.5 version file compare功能无法使用的问题
  • 三级网络技术应付式速成考试笔记(汇总)
  • 很高兴大家下载rapid-framework
  • Ubuntu 安装Sougou Pinyin输入法
  • InoReader—— 轻便快捷的在线 RSS 阅读器
  • Web开发设计:DisplayTag应用指南
  • 硬币面值组合(C++)(枚举)
  • 帝国CMS二次开发入门教程
  • 回发或回调参数无效。 问题的解决和思考
  • dreamweaver4.0--9.0序列码全(学习参考)(仅供记忆用)
  • 创建视图簇SE54并SE93赋予事务代码
  • 哔哩下载姬(downkyi)v1.4.0 B站视频下载工具 哔哩哔哩视频解析
  • 对Gamma校正的理解
  • use sentences perfectly
  • 爬虫登陆实战 --- QQ音乐扫码登陆!真不难!
  • 逻辑非运算“!”,双重非运算
  • [技巧攻略] Zombie Cafe攻略 僵尸咖啡厅图文详解+刷级攻略
  • Node.js可以做什么
  • 理解P值
  • 09、Swift中的class
  • 淘宝宝贝详情页设计指南:从构思到实现,打造高转化率的页面
  • 详解箭头函数和普通函数的区别以及箭头函数的注意事项、不适用场景
  • PL/SQL 例外(异常) exception
  • windows下钩子的使用
  • 设计测试用例(蘑菇街web的登录页面)