2024年2月21日发(作者:)

Centos开启远程桌面

VNC客户端下载地址:/soft/

配置服务器:

Rpm -qa | grep vncserver #查看是否安装vncserver服务

Yum install -y vnc-server #按章vncserver服务

Vi /etc/sysconfig/vncservers #编辑vncserver服务

找到最后两行

#VNCSERVERS="2:myusername" #"2"是桌面号 可以修改 修改后远程端口

就是5902 myusername修改为你要登陆

的用户名 一般修改为root即可

#VNCSERVERARGS[2]="-genmetry 800*600 *nolisten tcp -local

取消最后两行在 #,把命令注释取消,使命令生效;

vncserver #开始vncserver服务 输入后提示输入 访问密码

修改防火墙 开放要访问的端口号

Vi /etc/sysconfig/iptables #复制开房22端口的命令,把22改成要开放的端口号

Service iptables restart #重启防火墙服务

Service vncserver #重启vncserver服务

安装并运行VNC客户端,填写你的服务器IP和端口号就可以连接了

附录

login as: root

root@192.168.1.18's password:

[root@localhost ~]# yum install -y vnc-server

Loaded plugins: fastestmirror, refresh-packagekit

Loading mirror speeds from cached hostfile

* base:

* extras:

* updates:

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package tigervnc-server.i686 0:6 set to be updated

--> Processing Dependency: xorg-x11-fonts-misc for package:

6.i686

--> Running transaction check

---> Package 0:6 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

Package Arch Version Repository

Size

================================================================================

Installing:

tigervnc-server i686 6 base 1.1 M

Installing for dependencies:

xorg-x11-fonts-misc noarch 6 base 5.8 M

Transaction Summary

================================================================================

Install 2 Package(s)

Upgrade 0 Package(s)

Total download size: 6.9 M

Installed size: 9.7 M

Downloading Packages:

(1/2): 6.i | 1.1 MB 00:00

(2/2): | 5.8 MB 00:00

--------------------------------------------------------------------------------

Total 7.1 MB/s | 6.9 MB 00:00

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY

base/gpgkey | 3.3 kB 00:00 ...

Importing GPG key 0xC105B9DE "CentOS-6 Key (CentOS 6 Official Signing Key)

" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : 1/2

Installing : 6.i686 2/2

Installed:

tigervnc-server.i686 0:6

Dependency Installed:

0:6

Complete!

[root@localhost ~]# vi /etc/sysconfig/vncservers

[root@localhost ~]# vncserver

You will require a password to access your desktops.

Password:

Verify:

xauth: creating new authority file /root/.Xauthority

New 'omain:1 (root)' desktop is omain:1

Creating default startup script /root/.vnc/xstartup

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/omain:

[root@localhost ~]# vi /etc/sysconfig/iptables

[root@localhost ~]# service iptables restart

iptables: Flushing firewall rules: [ OK ]

iptables: Setting chains to policy ACCEPT: filter [ OK ]

iptables: Unloading modules: [ OK ]

iptables: Applying firewall rules: [ OK ]

[root@localhost ~]# service vncserver

Usage: /etc/init.d/vncserver {start|stop|restart|try-restart|status|force-reload}

[root@localhost ~]# ping 192.168.1.31

PING 192.168.1.31 (192.168.1.31) 56(84) bytes of data.

^C

--- 192.168.1.31 ping statistics ---

21 packets transmitted, 0 received, 100% packet loss, time 20947ms

[root@localhost ~]# service vncserver restart

Shutting down VNC server: 2:root [FAILED]

Starting VNC server: 2:root

New 'omain:2 (root)' desktop is omain:2

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/omain:

[ OK ]

[root@localhost ~]# vi /etc/sysconfig/iptables

[root@localhost ~]# vi /etc/sysconfig/vncservers

[root@localhost ~]# service iptables restart

iptables: Flushing firewall rules: [ OK ]

iptables: Setting chains to policy ACCEPT: filter [ OK ]

iptables: Unloading modules: [ OK ]

iptables: Applying firewall rules: [ OK ]

[root@localhost ~]# service vncserver restart

Shutting down VNC server: 1:root [ OK ]

Starting VNC server: 1:root

New 'omain:1 (root)' desktop is omain:1

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/omain:

[ OK

[root@localhost ~]#

]