RHEL7.2安裝VNC服務器

tigervnc 是client-server的工作模式,默認是不加密的,可以使用ssh forwarding map來加密這個連接

在rhel7之前tigervnc的配置文件被放在/etc/sysconfig/ 文件夾中

在rhel7中其配置文件放在/etc/systemd/system/ 中

每個用戶對應個配置文件,文件名如:vncserver-root (rhel7之前) ?vncserver-root@.service(rhel7)

vncserver 是一個能開啟vnc桌面的工具,它會使用適當選線來運行Xvnc 并在vnc 桌面上運行一個window manager。

vncserver允許多個會話同時并行訪問一臺主機,允許多個用戶從任何地方訪問某臺主機


服務端安裝:

yum install tigervnc-server

客戶端安裝:

yum install tigervnc

配置:

示例配置文件是 /lib/systemd/system/vncserver@.service內(nèi)容如下:

[Unit]

Description=Remote desktop service (VNC)

After=syslog.target network.target

[Service]

Type=forking

# Clean any existing files in /tmp/.X11-unix environment

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

ExecStart=/sbin/runuser -l -c "/usr/bin/vncserver %i [-geometrysize]" ? ? ? ? ? ?//可以使用具體的用戶名替換掉,一旦這個服務開啟這個用戶就可以登錄了,%i,代表的是window號碼,這個號碼是唯一,systemd會自動根據(jù)用戶在啟動該unit時指定的window號碼來替換。 ?-geometrysize:指定桌面分辨率,如果不指定,則size默認為1024*768

PIDFile=/home//.vnc/%H%i.pid ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//同上

ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]

WantedBy=multi-user.target

******可以為多個用戶創(chuàng)建多個 unit file,然后給它們一個唯一名,并放到 /etc/systemd/system中,當某個用戶需要使用遠程桌面時,就啟動對應的unit file。

文件配置完成后,需要重新整理systemd依賴關(guān)系,只要修改了unit file就要重新整理:

systemctl ?daemon-reload

修改vnc連接的密碼:

su - username

vncpasswd

密碼必須設置否則無法登陸

啟動:

systemctl start vncserver-username@:window_number.service

開機就啟動某個window

systemctl enable vncserver-username@:window_number.service

客戶端連接:

客戶端程序vncviewer

輸入vncserver地址和窗口號:vncserver:window_number

輸入vnc-password

為 vnc 配置防火墻:

使用非加密的鏈接,默認會被firewalld blocked 掉,想要 vnc正常工作就需要讓firewalld開放相應的端口才行。

vnc默認的端口號為5900,而每個vnc window的端口號是: 5900+window_number(or,display_number)

如:systemctl start vncserver-username@:2.service ?那么這個vnc window的端口號就是 5902

設置:

firewall-cmd --list-all ? //查看防火墻規(guī)則

firewall ? --add-rich-rule='rule family="ipv4" source address="client_ip" service name=service_name accept' ? ?//[--permanent] 指定是否永久生效, --zone指定將該rule放到哪個zone當中,這樣從這個地址來的任何流量都可以通過??!

也可以只打開指定端口:

firewall-cmd --zone=public --add-port=590*/tcp

使用ssh連接:

vncviewer-viausername@vncserverlocalhost:window_number ? (使用 ssh forwarding)//localhost一定要加,否則無法連接

避免使用不安全的鏈接:

將unit file中的 ExecStart=/sbin/runuser -l user -c "/usr/bin/vncserver-localhost%i"

-localhost 參數(shù)可以讓vncserver不接受 除本機及ssh forwarding 以外的任何連接。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

  • muahao閱讀 2,166評論 0 3
  • Openstack Mitaka安裝部署教程 一、實驗環(huán)境: 系統(tǒng):centos7.2-minimal 網(wǎng)絡:管理...
    指間_流年閱讀 2,323評論 0 0
  • VNC允許Linux系統(tǒng)可以類似實現(xiàn)像Windows中的遠程桌面訪問那樣訪問Linux桌面。 首先試試服務器裝了V...
    一指彈風閱讀 3,086評論 0 2
  • systemd攻略 相關(guān)文檔 arch 的 systemd 說明頁面 (簡體中文) fedora 的 system...
    muahao閱讀 11,968評論 0 12
  • #!/bin/sh# Uncomment the following two lines for normal d...
    kf92閱讀 21,984評論 1 3

友情鏈接更多精彩內(nèi)容