Centos7远程桌面 vnc/vnc-server的设置
Centos7与Centos6.x有了很大的不同。
为了给一台服务器装上远程桌面,走了不少弯路。写这篇博文,纯粹为了记录,以后如果遇到相同问题,可以追溯。
1、假定你的系统没有安装vnc的任何软件,那么,首先安装vnc
|
1
|
yum -y install tigervnc-server tigervnc |
2、Centos7之前的系统,如果安装vnc一般都需要配置
|
1
2
|
[root@localhost ~]# cat /etc/sysconfig/vncservers # THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service |
但是,如上所述,Centos7需要配置的文件在
|
1
2
|
[root@localhost ~]# ll /lib/systemd/system/vncserver@.service-rw-r--r--. 1 root root 1744 Jun 10 14:15 /lib/systemd/system/vncserver@.service |
3、文件内有如下提示
|
1
2
3
4
5
6
|
# Quick HowTo:# 1. Copy this file to /etc/systemd/system/vncserver@:<display>.service# 2. Edit <USER> and vncserver parameters appropriately# ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")# 3. Run `systemctl daemon-reload`# 4. Run `systemctl enable vncserver@:<display>.service |
4、复制一份文件,并改名为vncserver@:1.service
|
1
|
[root@localhost ~]# cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service |
5、将文件中的<User>用你当前的用户替换,将%i替换为1
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=forking# Clean any existing files in /tmp/.X11-unix environmentExecStartPre=/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.pidExecStop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'[Install]WantedBy=multi-user.target |
6、更新systemctl
|
1
|
systemctl daemon-reload |
7、设置为自动启动
|
1
|
systemctl enable vncserver@:1.service |
8、启动vnc服务
|
1
|
systemctl start vncserver@:1.service |
9、在iptables中加入对应的端口5901(注意,如果有其他用户,那么也需要将端口加上。vnc的端口默认是5900 + n)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@localhost system]# cat /etc/sysconfig/iptables# sample configuration for iptables service# you can edit this manually or use system-config-firewall# 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-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT |
注意:
1、如果你不配置和启用防火墙,此时用VNC Viewer连接的话,会报:"connect:Connection timed out(10060)"错误。
2、本文是以root用户为例,如果其他用户也需要登录,那么,还需要将文件复制为
|
1
|
cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:2.service |
同时,将文件内的%i改为2,并建立对应用户的vncpasswd。
3、你可以通过UltraVNC,TigerVNC或者RealVNC Viewer进行访问,我在win7下使用这3中工具均能连接
Centos7远程桌面 vnc/vnc-server的设置的更多相关文章
- VNC连接CentOS7远程桌面
1.在centos7安装图形化 先安装图形用户接口X Window System,再安装GNOME桌面. [root@centos7 ~]# yum groupinstall -y "X W ...
- ubuntu远程桌面、VNC(转载)
VNC 远程桌面 配置/使用 for xfce 本贴主要目的为说明如何在windows系统下远程控制xfce桌面 Ubuntu 的默认GNOME桌面可以在系统设置中直接打开远程桌面,然后用Window ...
- 【一步一步走(1)】远程桌面软件VNC的安装与配置
近期在VPS上搭建Python Web环境.走了非常多弯路,借此记下. 先说说购买的VPS(PhotonVPS),我可不是打广告.仅仅是感觉这个VPS服务提供商还不错推荐给你大家,我之前也是体验过阿里 ...
- Mac上远程桌面连接Windows Server 2012 R2
在将一台服务器的操作系统由Windows Server 2012升级为Windows Server 2012 R2之后,在Mac电脑上用微软的远程桌面软件怎么也连不上服务器,错误信息如下: Remot ...
- xp远程桌面连接最大用户数怎么设置?
1.首先到网上去百度下载“补丁UniversalTermsrvPatch”,这个补丁主要目的是在于去除“单用户登陆的限制”,允许多人多用户同时并行访问登录;2.然后根据自己的系统运行对应的程序:系统是 ...
- Win10使用VNC连接Centos7远程桌面
一.安装VNC Viewer 1.首先win10下载安装VNC VIEWER 或者直接下载绿色版 2.linux系统安装vnc: 检查linux是否安装vnc:rpm -q tigervnc tige ...
- linux远程桌面连接 VNC Server
更新源 # sudo apt-get update 安装vnc4server # sudo apt-get install vnc4server 修改vnc远程连接密码 # vncpasswd 编辑v ...
- ubuntu远程桌面软件vnc。
http://www.linuxidc.com/Linux/2017-03/141936.htm 现在Linux是非常火的 很多人喜欢用它,界面简单,操作容易,有很多图形化工具如WinSCP可以与U ...
- centos7 远程桌面连接到xfce桌面
1 安装xfce $ sudo yum install -y epel-release $ sudo yum groupinstall -y "Xfce" $ sudo reboo ...
随机推荐
- ASP.NET MVC5 学习系列之初探MVC
一.由问题看本质 (一)什么是MVC? MVC是Model-View-Controller的简称.它是在1970年引入的软件设计模式.MVC 模式强迫关注分离 — 域模型和控制器逻辑与UI是松耦合关系 ...
- POJ 3744 Scout YYF I 概率dp+矩阵快速幂
题目链接: http://poj.org/problem?id=3744 Scout YYF I Time Limit: 1000MSMemory Limit: 65536K 问题描述 YYF is ...
- 团队作业4——第一次项目冲刺(Alpha版本)2017.11.14
1.当天站立式会议照片 本次会议在5号公寓1楼召开,本次会议内容:①:熟悉每个人想做的模块.②:根据老师的要求将项目划分成一系列小任务.③:选择项目的开发模式:jsp+servlet+javabean ...
- React---点击按钮实现内容复制功能
思路: 1.给要复制的内容容器添加一个标签(可以是ID,可以是类名等),通过dom技术获取该容器对象: 2.创建Range对象(某个区域内连续的内容),把该容器对象放进去: 3.将Range对象添加到 ...
- javascript 组件化(转载)
这边只是很简陋的实现了类的继承机制.如果对类的实现有兴趣可以参考我另一篇文章javascript oo实现 我们看下使用方法: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
- 1014 C语言文法定义与C程序的推导过程
<程序> -> <外部声明> | <程序> <外部声明> <外部声明> -> <函数定义> | <声明> ...
- [转帖]HR职能划分三支柱模型
HR职能划分三支柱模型 http://blog.sina.com.cn/s/blog_afbd12640101o5hf.html COE(Centre of Excellence or Center ...
- SpannableString的基本用法
原文地址:http://www.cnblogs.com/kross/p/3645594.html 以前一直好奇QQ的输入框里面是如何出现表情的,今天看了下这个,心中发出“原来是这样啊”的感叹. 通常情 ...
- 重新认识javascript的settimeout和异步
1.简单的settimeout setTimeout(function () { while (true) { } }, 1000); setTimeout(function () { alert(' ...
- 静态属性加载到jvm时候就存放在数据共享区,而不是等new后出现
静态属性加载到jvm时候就存放在数据共享区,而不是等new后出现.他的生命周期是 jvm结束 才会消失,一般的方法属性是对象结束后 就会消失.