Centos7远程桌面 vnc/vnc-server的设置详解
Centos7与Centos6.x有了很大的不同。
为了给一台服务器装上远程桌面,走了不少弯路。写这篇博文,纯粹为了记录,以后如果遇到相同问题,可以追溯。
1、假定你的系统没有安装vnc的任何软件,那么,安装vnc
yum -y install tigervnc-server tigervnc
2、Centos7之前的系统,如果安装vnc一般都需要配置
[root@localhost ~]# cat /etc/sysconfig/vncservers # THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service
,如上所述,Centos7需要配置的文件在
[root@localhost ~]# ll /lib/systemd/system/vncserver@.service -r-r--r--. 1 root root 1744 Jun 10 14:15 /lib/systemd/system/vncserver@.service
3、文件内有如下提示
# Quick HoTo: # 1. Copy this file to /etc/systemd/system/vncserver@:.service # 2. Edit and vncserver parameters appropriately # ("runuser -l -c /usr/bin/vncserver %i -arg1 -arg2") # 3. Run `systemctl daemon-reload` # 4. Run `systemctl enable vncserver@: .service
4、复制一份文件,并改名为vncserver@:1.service
[root@localhost ~]# cp /lib/systemd/system/vncserver@.service/lib/systemd/system/vncserver@:1.service
5、将文件中的
[Unit] Description=Remote desk service (VNC) After=syslog.target ork.target [Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :' ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver :1 -geometry 1280x720 -depth 24" PIDFile=/root/.vnc/%H%i.pid ExecS=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target
6、更新systemctl
systemctl daemon-reload
7、设置为自动启动
systemctl enable vncserver@:1.service
8、启动vnc服务
systemctl start vncserver@:1.service
9、在iptables中加入对应的端口5901(注意,如果有其他用户,那么也需要将端口加上。vnc的端口默认是5900 + n)
[root@localhost system]# cat /etc/sysconfig/iptables # sample configuration for iptables service # you can edit this manually or use system-config-fireall # please do not ask us to add additional ports/services to this default configuration filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT -A INPUT -j REJECT --reject-ith icmp-host-prohibited -A FORWARD -j REJECT --reject-ith icmp-host-prohibited COMMIT
注意
1、如果你不配置和启用防火墙,此时用VNC Vieer连接的话,会报"connectConnection timed out(10060)"错误。
2、本文是以root用户为例,如果其他用户也需要登录,那么,还需要将文件复制为
cp /lib/systemd/system/vncserver@.service/lib/systemd/system/vncserver@:2.service
,将文件内的%i改为2,并建立对应用户的vncpassd。
3、你可以通过UltraVNC,TigerVNC或者RealVNC Vieer进行访问,我在in7下使用这3中工具均能连接
感谢阅读,电脑维修网希望能帮助到大家,谢谢大家对本站的支持!
空调维修
- 温岭冰箱全国统一服务热线-全国统一人工【7X2
- 荆州速热热水器维修(荆州热水器维修)
- 昆山热水器故障码5ER-昆山热水器故障码26
- 温岭洗衣机24小时服务电话—(7X24小时)登记报
- 统帅热水器售后维修服务电话—— (7X24小时)登
- 阳江中央空调统一电话热线-阳江空调官方售后电
- 乌鲁木齐阳春燃气灶厂家服务热线
- 珠海许昌集成灶售后服务电话-全国统一人工【
- 乌鲁木齐中央空调维修服务专线-乌鲁木齐中央空
- 新沂热水器故障电话码维修-新沂热水器常见故障
- 诸城壁挂炉24小时服务热线电话
- 靖江空调24小时服务电话-——售后维修中心电话
- 空调室外滴水管维修(空调室外排水管维修)
- 九江壁挂炉400全国服务电话-(7X24小时)登记报修
- 热水器故障码f.22怎么解决-热水器f0故障解决方法
- 营口热水器售后维修服务电话—— 全国统一人工