文档库 最新最全的文档下载
当前位置:文档库 › 开启linux远程桌面

开启linux远程桌面

****VNC方式:**********************************************
--------------------------
1 安装VNC服务端
#yum install vnc-server
2 配置VNC服务参数文件
编辑vncservers文件追加如下
#vi /etc/sysconfig/vncsevers
VNCSERVERS="1:root 2:ivvr 3:abcd "
VNCSERVERARGS[1]="-name root -geometry 1280x720"
VNCSERVERARGS[2]="-name ivvr -geometry 800x600"
VNCSERVERARGS[3]="-name abcd -geometry 1280x720"
为VNC服务配置了3个用户root、ivvr和abcd,他们使用的端口号分别为5901、5902和5903,分辨率分别为1280x720、800x600和1280x720。
3 为使用VNC服务的用户设置密码
这一步需要切换到各自的账户下使用vncpasswd来生成访问VNC服务的密码
#su – ivvr
$vncpasswd
Password:
Verify:
这样在各自家目录下会生成一个.vnc的隐藏目录,其下面会生成一个名为passwd的存储用户密码的文件。
4 启动VNC服务
#service vncserver start
或者
#/etc/init.d/vncserver start
5 修改各用户桌面环境
启动VNC服务后在相应的用户的家目录下就会生成一个隐藏的vnc目录和下属xstartup文件
$vi /home/ivvr/.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" &
gnome-session &
#twm &
我们通过注释twm &且添加gnome-session &来使通过vnc-viewer登陆的用户使用gnome桌面环境。
6 重新启动VNC服务
#service vncserver restart
7 配置防火墙
在防火墙上为VNC server开启端口,服务的默认端口是TCP 5900,加上/etc/sysconfig/vncservers文件里配置的号,结果就是我们需要开启的端口,本例子为5901、5902和5903.
--------------------------




****Xmanager方式********************************************
--------------------------
配置步骤:
1. 改变linux的运行级别为5
Open /etc/inittab and set the initial runlevel to 5 asfollowing:
# id:5:initdefault:
最下面一行
# x:5:respawn:/usr/sbin/gdm
2. 配置xdmcp
2.1对于GDM:
Open /etc/gdm/custom.conf and set the Enable entry to 1 in the [xdmcp] section as following.
[xdmcp]
Enable=1 或 true
Port=177
[security]
AllowRemoteRoot=true
# 如果需要允许root用户登录,设置此项为true

2.2对于KDM:
Open /usr/share/config/kdm/Xaccess and remove the initial "#" characterfor the following line:
#* #any host can get a login window ==>
* #any host can get a login window
Open /usr/share/config/kdm/kdmrc and set the Enable entryto true in the [xdmcp] section as following.
[xdmcp]
Enable=true
3. 配置防火墙
如果我们的Linux机器配置有防火墙,为防止防火墙将通过177端口(即xdmcp服务)的数据过虑,我们必须加上如下的规则:
iptables -A

INPUT -p udp -s 0/0 -d 0/0 --dport 177 -j ACCEPT
4.重启服务:gdm-restart
5.重启linux服务器
# init 3; init 5

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




****防火墙设置**********************************************
-------------------------
1.即时生效,重启后失效

# 开启: service iptables start

# 关闭: service iptables stop

2.重启后生效

# 开启: chkconfig iptables on

# 关闭: chkconfig iptables off

3.在开启了防火墙时,做如下设置,开启相关端口

修改/etc/sysconfig/iptables 文件,添加以下内容:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT //开启自定义端口

修改防火墙配置需要修改 /etc/sysconfig/iptables 这个文件,如果要开放哪个端口,在里面添加一条。

-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

就可以了,其中 80 是要开放的端口号,然后重新启动linux的防火墙服务。



#############################################
1.关闭SELinux
# 修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
# 如果不想重启系统,使用命令setenforce 0
2.在防火墙中添加177端口
# 修改/etc/sysconfig/iptables 文件,添加以下内容:
# -A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 177 -j ACCEPT
# 然后重启防火墙
# /sbin/service iptables restart //重新启动防火墙
#############################################

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

相关文档
相关文档 最新文档