1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > linux上安装部署vnc远程服务

linux上安装部署vnc远程服务

时间:2022-08-02 11:34:16

相关推荐

linux上安装部署vnc远程服务

本文操作环境为:

[root@localhost ~]# uname -aLinux localhost.localdomain 4.19.90-17.ky10.aarch64 #1 SMP Sun Jun 28 14:27:40 CST aarch64 aarch64 aarch64 GNU/Linux[root@localhost ~]# [root@localhost ~]# cat /etc/os-release NAME="Kylin Linux Advanced Server"VERSION="V10 (Tercel)"ID="kylin"VERSION_ID="V10"PRETTY_NAME="Kylin Linux Advanced Server V10 (Tercel)"ANSI_COLOR="0;31"[root@localhost ~]#

1、查看是否已经安装tigervnc-server

[root@localhost ~]# rpm -aq | grep tigertigervnc-1.10.1-2.p01.ky10.aarch64tigervnc-server-minimal-1.10.1-2.p01.ky10.aarch64[root@localhost ~]#

2、安装tigervnc-server

[root@localhost ~]# yum install -y tigervnc-serverfirmware for qemu, built by jenkins, fresh from git repos3.3 kB/s | 3.0 kB00:00 firmware for qemu, built by jenkins, fresh from git repos2.7 kB/s | 6.6 kB00:02 Kylin Linux Advanced Server 10 - Os 47 kB/s | 3.7 kB00:00 Dependencies resolved.==============================================================================================================================================================================Package Architecture VersionRepository Size==============================================================================================================================================================================Installing:tigervnc-server aarch64 1.10.1-2.p01.ky10ks10-adv-os 212 kTransaction Summary==============================================================================================================================================================================Install 1 PackageTotal download size: 212 kInstalled size: 605 kDownloading Packages:tigervnc-server-1.10.1-2.p01.ky10.aarch64.rpm 990 kB/s | 212 kB00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total 981 kB/s | 212 kB00:00Running transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded.Running transactionPreparing :1/1 Installing : tigervnc-server-1.10.1-2.p01.ky10.aarch64 1/1 Running scriptlet: tigervnc-server-1.10.1-2.p01.ky10.aarch64 1/1 Verifying : tigervnc-server-1.10.1-2.p01.ky10.aarch64 1/1 Installed:tigervnc-server-1.10.1-2.p01.ky10.aarch64 Complete![root@localhost ~]# rpm -aq | grep tigertigervnc-1.10.1-2.p01.ky10.aarch64tigervnc-server-minimal-1.10.1-2.p01.ky10.aarch64tigervnc-server-1.10.1-2.p01.ky10.aarch64[root@localhost ~]#

3、配置vncserver服务脚本

[root@localhost ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service[root@localhost ~]#

修改该配置,按照脚本中注释部分:

# Quick HowTo:

# 1. Copy this file to /etc/systemd/system/vncserver@.service

# 2. Replace <USER> with the actual user name and edit vncserver

# parameters appropriately

# 3. Run `systemctl daemon-reload`

# 4. Run `systemctl enable vncserver@:<display>.service`

修改图中红色框路径为指定用户的home路径,user、group改为对应的用户及组即可。如果为root用户,则红框内路径都改为/root/即可,user、group也为root。

4、设置vnc密码

[root@localhost system]# vncpasswd Password:Verify:Would you like to enter a view-only password (y/n)? yPassword:Verify:[root@localhost system]#

5、设置开机启动

[root@localhost system]# systemctl daemon-reload[root@localhost ~]# systemctl enable vncserver@\:1.service Created symlink /etc/systemd/system/multi-user.target.wants/vncserver@:1.service → /etc/systemd/system/vncserver@:1.service.[root@localhost ~]#

6、开启服务

[root@localhost system]# systemctl start vncserver@\:1.service Job for vncserver@:1.service failed because the control process exited with error code.See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.[root@localhost system]#

这里启动失败的话,可以执行执行vncserver来启动vnc服务:

[root@localhost system]# vncserver New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost.localdomain:1.log[root@localhost system]#

7、查看启动的vnc服务

[root@localhost system]# vncserver -listTigerVNC server sessions:X DISPLAY #PROCESS ID:1 139265[root@localhost system]#

注:这里:1对应远程连接端口5901,如果为:2则远程连接端口为5902,依次类推。

此时可以通过ss命令查看到5901端口已经有了:

[root@localhost system]# ss -tanp | grep 590 LISTEN 05 0.0.0.0:5901 0.0.0.0:*users:(("Xvnc",pid=139670,fd=6))[root@localhost system]#

到这里,vnc服务已经启动,如果端口没被禁的话,已经可以远程连接上来了

8、最后开端口,590x开放,以5901为例

①简单粗暴的方法就是把防火墙停掉:

[root@localhost ~]# service iptables stopRedirecting to /bin/systemctl stop iptables.service[root@localhost ~]# [root@localhost ~]# [root@localhost ~]# service firewalld stopRedirecting to /bin/systemctl stop firewalld.service[root@localhost ~]#

②开放指定端口

若系统使用的防火墙为iptables,则在 /etc/sysconfig/iptables 文件中添加如下规则:

-A INPUT -p tcp -m tcp --dport 5901 -j ACCEPT

之后重启iptables:

service iptables restart

若系统使用的是firewalld服务,则可以:

firewall-cmd --zone=pulic --add-port=5901/tcp --permanent

之后重载规则:

firewall-cmd --reload

9、vnc viewer连接远程

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。