Linux Mint:VNC Server配置

作者 : 开心源码 本文共3223个字,预计阅读时间需要9分钟 发布时间: 2022-05-13 共212人阅读

本文主要详情Linux Mint(Cinnamon)下VNC Server的基本配置。

测试环境:Linux Mint 19.2 Cinnamon + TigerVNC 1.7.0 + VNC-Viewer(WIN10)

安装vncserver

sudo apt install tigervnc-standalone-server tigervnc-common

设置密码

使用vncpasswd命令设置密码,文件存放在~/.vnc路径下。

$ vncpasswdPassword:Verify:Would you like to enter a view-only password (y/n)? n$ ls  ~/.vncpasswd

设置为开机启动

创立/etc/systemd/system/vncserver@:1.service文件,具体内容为:

[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=simpleUser=txflyPAMName=loginPIDFile=/home/%u/.vnc/%H%i.pidExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/bin/vncserver %i -geometry 1440x900 -alwaysshared -fg -localhost noExecStop=/usr/bin/vncserver -kill %iRestart=always[Install]WantedBy=multi-user.target

其中需要注意的有:

  1. 修改User=txfly为真实客户名;
  2. ExecStart=/usr/bin/vncserver %i -geometry 1440x900 -alwaysshared -fg -localhost no-fg表示进程在前端运行并在VNC服务器的X会话终止后终止它,-localhost no表示所有用户端都可以连接。
  3. Restart=always重启VNC Server。在用户端注销后,可以重新连接服务器。假如没有加这一条,用户端注销后,vncserver@:1.service会变成stop状态。

详细操作步骤:

$ sudo /etc/systemd/system/vncserver@:1.service$ sudo systemctl start vncserver@:1.service$ sudo systemctl enable vncserver@:1.serviceCreated symlink /etc/systemd/system/multi-user.target.wants/vncserver@:1.service → /etc/systemd/system/vncserver@:1.service.$ sudo systemctl status vncserver@:1.service● vncserver@:1.service - Remote desktop service (VNC)   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: enabled)   Active: active (running) since Tue 2019-12-10 15:21:27 CST; 5s ago  Process: 4385 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS) Main PID: 4392 (vncserver)    Tasks: 0 (limit: 4915)   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service           ? 4392 /usr/bin/perl /usr/bin/vncserver :1 -geometry 1440x900 -alwaysshared -fg -localhost no

连接VNC Server

打开VNC-Viewer,地址栏输入ip地址和端口就可,例如192.168.2.6:5901(注意此时端口号是5901)。

登录连接后界面

假如出现连接超时或者者服务端拒绝连接,需要在Linux Mint里面关闭防火墙,或者者将5901增加到防火墙里面,配置方式如下:

配置防火墙

其它需要注意的地方:
1. 启用剪切复制功能
修改/etc/X11/Xvnc-session文件,将vncconfig -iconic &修改成vncconfig -nowin &,这样可以隐藏helper应用,修改后的内容为:

#! /bin/shtest x"$SHELL" = x"" && SHELL=/bin/bashtest x"$1"     = x"" && set -- defaultvncconfig -nowin &$SHELL -l <<EOFexec /etc/X11/Xsession "$@"EOFvncserver -kill $DISPLAY

2. 修复文件管理器以Root身份打开功能
修改/usr/share/polkit-1/actions/org.nemo.root.policy文件,将<allow_any>no</allow_any>改成<allow_any>auth_admin_keep</allow_any>,修改后的内容如下:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE policyconfig PUBLIC"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN""http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd"><policyconfig> <vendor>Nemo Project</vendor> <vendor_url> linuxmint/nemo</vendor_url> <action id="org.nemo.root">   <description>Run Nemo with elevated privileges</description>   <message gettext-domain="nemo">Files</message>   <icon_name>gksu-root-terminal</icon_name>   <defaults>     <allow_any>auth_admin_keep</allow_any>     <allow_inactive>no</allow_inactive>     <allow_active>auth_admin_keep</allow_active>   </defaults>   <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/nemo</annotate>   <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> </action></policyconfig>

参考连接:

  1. https://wiki.archlinux.org/index.php/TigerVNC
  2. https://tigervnc.org/doc/vncconfig.html

版权公告:本文为「txfly」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本公告。
原文链接:https://www.songma.com/p/c23714457783

说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » Linux Mint:VNC Server配置

发表回复