CentOS和Windows互相远程桌面方法
首先安装tigervnc-server:
yum install tigervnc-server
安装好后,设置 vi /etc/sysconfig/vncservers
[root@gateway-001 ~]# cat /etc/sysconfig/vncservers
# 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 this URL:
# https://access.redhat.com/knowledge/solutions/7027
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# 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="1:root"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERS="2:work"
VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -localhost"
service vncserver start
切换到work用户,设置vncpasswd
在服务器上可以看到打开的vnc端口:
在windows上安装viewvnc,输入ip地址和端口号进行连接:
/etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6000:6010 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 177 -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
关闭防火墙: /etc/init.d/iptables stop 使用root账号
- yum install -y vnc-server
- vi /etc/sysconfig/vncservers
- vncserver
- vi /etc/sysconfig/iptables
VNC服务使用的端口号与桌面号相关,VNC使用TCP端口从5900开始,对应关系如下:
桌面号为“1” ---- 端口号为5901
桌面号为“2” ---- 端口号为5902
桌面号为“3” ---- 端口号为5903
……
- service iptables restart
- service vncserver restart
- yum install -y rdesktop
- rdesktop -a 16 x.x.x.x:3389 -u username -p password -f
1、安装VNC
yum install vnc-server
2、添加多个用户用户
useradd user1 //添加用户user1
passwd user1 //设置用户的linux登录密码
su user1 //切换到用户user1
vncpasswd //设置用户的user1登录密码
exit
useradd user2 //添加用户user2
passwd user2 //设置用户的linux登录密码
su user2 //切换到用户user2
vncpasswd //设置用户的user2登录密码
exit
3、编辑vnc配置文件
vi /etc/sysconfig/vncservers
在最后加上:
VNCSERVERS="1:user1 2:user2"
VNCSERVERSVNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared"
VNCSERVERSVNCSERVERARGS[2]="-geometry 1024x768 -alwaysshared"
注意:-geometry 1024x768表示分辨率;-alwaysshared 表示允许多终端同时登陆
4、打开对应的端口打开5901至5902 端口用于vnc //如果需要配置更多的桌面,增加端口即可
iptables -I INPUT -p tcp --dport 5901:5902 -j ACCEPT
iptables -A INPUT -p tcp --dport 5901:5902 -j ACCEPT
永久保存
service iptables save
4.启动vncserver服务
1)启动全部桌面
service vncserver start
2)启动某一桌面
vncserver :1 //这里1表示第一个桌面
5、停止vncserver服务1)停止全部桌面
service vncserver stop
2) 停止某一桌面
vncserver -kill :1 //停止第1个界面,要用kill命令来杀掉界面1的进程
6、查看当前有几个桌面在运行 service vncserver status
7、让vncserver服务随机启动默认状态下,vncserver服务不是开机自动启动,需要手工启动。
chkconfig --list vncserver
chkconfig vncserver on
保存后,重启测试。
8.客户端登录vncserver服务(1)先安装vncviewer来远程登录,
(2)然后在地址栏输入“主机地址:1”(即主机IP加界面号的方式)
9、开机自动启动vncserver
# chkconfig vncserver on
查看是否设置成功
10、关闭自动启动
# chkconfig vncserver off
查看是否关闭自动启动