VNC服务端

VNC有很多种服务端,选择一个自己认为合适的就好。

Ubuntu 16

x11vnc

一键安装脚本,服务端为x11vnc
在Ubuntu 16.04 LTS上正常运行,其它版本有待测试。
VNC有很多选择,VNC4server,tigervncserver等等,都不推荐,难装又难用。其中x11vnc应该是比较好用的一种。

一键安装脚本:https://image.leolan.top/Ubuntu16_autoinstall_VNC.sh
安装:
请切换到root用户再执行脚本

wget https://image.leolan.top/Ubuntu16_autoinstall_VNC.sh
chmod u+x Ubuntu16_autoinstall_VNC.sh
./Ubuntu16_autoinstall_VNC.sh

安装完成后重启系统才生效,连接时输入IP即可,端口是默认的5899(在安装了KVM的主机上可能会占用5900端口)。


Centos

x11VNC

一键安装脚本,服务端为x11vnc
在Centos 7 上正常运行,其它版本有待测试。

# #################################################################
# 脚本名称 : Centos 7_autoinstall_VNC
# 脚本描述 : 自动安装配置和自动启动X11Vnc
# 免责声明 : 使用自由,自行承担后果 
# #################################################################

# 安装依赖库
yum install -y xorg-x11-xauth xterm libXi libXp libXtst libXtst-devel libXext libXext-devel
# Xvfb 是一个轻量级 Xorg(图形用户程序的必备条件)服务程序。不产生实际屏幕输出的虚拟 display 服务程序。
yum install -y Xvfb


# 步骤 1 - 安装 X11VNC  
# ################################################################# 
# x11vnc 是轻量级 VNC 服务程序,转换其他协议为VNC协议。
yum install x11vnc -y

# 步骤 2 - 配置访问密码
# ################################################################# 

x11vnc -storepasswd /etc/x11vnc.pass 
# x11vnc -storepasswd [passwd] /etc/x11vnc.pass

# 步骤 3 - 创建服务
# ################################################################# 

cat > /lib/systemd/system/x11vnc.service << EOF
[Unit]
Description=Start x11vnc at startup.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5899 -shared

[Install]
WantedBy=multi-user.target
EOF

# 步骤 4 - 配配置防火墙端口,配置和启动服务
# ################################################################ 
# 防火墙放行端口,防火墙已关闭的忽略
echo "Configure firewall"
firewall-cmd --zone=public --add-port=5899/tcp --permanent

# 如果没有使用firewalld而是使用了iptables,就启用以下部分。
# /sbin/iptables -I INPUT -p tcp --dport 5899 -j ACCEPT
# /etc/init.d/iptables save
# service iptables restart

echo "Configure Services"
systemctl enable x11vnc.service
systemctl start x11vnc.service
systemctl daemon-reload

# 步骤 5 - 重启
# ################################################################ 
sleep  5s
echo "Please reboot system !!! Default Port:5899"


tigervnc

yum install tigervnc-server -y
# 配置密码,输入两次,第三次是读取配置文件的密码,可以选no
vncpasswd


# 默认是5901端口,更改端口(方便kvm)
vim /usr/bin/vncserver

# 搜索5900,有两个地方要改
$vncPort = 5900 + $displayNumber;改为$vncPort = 5899;
5900 + $n 改为5899

# 启动,就能看到5899端口了
vncserver

# 服务管理
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver.service
vim /etc/systemd/system/vncserver.service
#修改USER为用户名,如果是root,路径则是/root
systemctl daemon-reload

systemctl start vncserver.service

参考:
https://linux.cn/article-5335-1.html


源码编译

yum install "X*" -y
yum install xorg-x11-xauth xterm libXi libXp libXtst libXtst-devel libXext libXext-devel Xvfb

wget http://softlayer-ams.dl.sourceforge.net/project/libvncserver/x11vnc/0.9.13/x11vnc-0.9.13.tar.gz
tar zxf x11vnc-0.9.13.tar.gz
cd x11vnc-0.9.13
./configure
make
make install

# 启动
/usr/local/bin/x11vnc -rfbport 5899 -passwd 连接密码 -create -forever -shared

参考:http://blog.creke.net/811.html


tigervnc

yum -y install vnc-server tigervnc tigervnc-server

vim /root/.vnc/xstartup
把最后一行 twm & 注释掉,然后添加一行内容gnome-session &
然后保存退出

vim /etc/sysconfig/vncservers
修改一下最后两行如下

VNCSERVERS="1:root 2:root"
VNCSERVERARGS[2]="-geometry 1366x768 -nolisten tcp -localhost"

然后保存退出

vncserver 设置密码

最后启动vncserver 并设置为开机启动,【如果系统防火墙不会用,就关闭吧】

service vncserver start
chkconfig vncserver on
service iptables stop
chkconfig iptables on

现在vncserver服务器端已经配置好了,使用客户端进行图形界面远程即可。注意vnc远程的时候,默认第一个端口是5901,第二个界面是 5902依次类推。所以在使用vnc客户端远程的时候,要注意。否则连接不上的。


VNC修改分辨率

创建/etc/X11/xorg.conf,输入以下内容,Virtual后的就是分辨率。

Section "Device"
        Identifier "Configured Video Device"
        Option "NoLogo" "True"
EndSection

Section "Monitor"
        Identifier "Configured Monitor"
EndSection

Section "Screen"
        Identifier "Default Screen"
        Monitor "Configured Monitor"
        Device "Configured Video Device"
        SubSection "Display"
                   Depth 24
                   Virtual 1680 1050
        EndSubSection
EndSection

Teamviewer

官网下载最新版本:https://www.teamviewer.com/en/download
Linux版下载:https://www.teamviewer.com/en/download/linux/

teamviewer                     #启动teamviewer
teamviewer --help              #查看帮助
teamviewer passwd 12345        #设置连接密码为12345
teamviewer daemon restart      #重启服务
teamviewer daemon enable       #开机自启动
teamviewer info                #查看连接ID
# 然后就可以用ID和设置的密码进行连接了。

Centos

# 看上一节,去官方下载最新版
wget https://download.teamviewer.com/download/teamviewer.i686.rpm
#这里用yum方式安装可以自动解决依赖问题,路径要用绝对路径。
yum install /root/teamviewer_12.0.71510.i686.rpm   

Ubuntu

如何在Ubuntu 18.04上安装TeamViewer
https://www.linuxidc.com/Linux/2018-05/152282.htm

# 安装32位支持包
sudo apt-get install libc6:i386 libgcc1:i386 libasound2:i386 libexpat1:i386 libfontconfig1:i386 libfreetype6:i386 libjpeg62:i386 libpng12-0:i386 libsm6:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i386 libxinerama1:i386 libxrandr2:i386 libxrender1:i386 libxtst6:i386 zlib1g:i386

# 解决依赖问题
sudo apt-get update
sudo apt-get install -f

# 安装Teamviewer
wget https://download.teamviewer.com/download/teamviewer_i386.deb
sudo dpkg -i teamviewer_i386.deb

MAC

下载安装镜像,安装后即可使用。


远程桌面

vnc客户端有很多种,在chrome浏览器里也有插件版的客户端。需要有公网IP的要设置端口转发;当然,如果上用局域网IP就没有这些限制了。

Windows远程Windows系统

用自带的mstsc.exe程序就很好,不需要安装第三方软件(需要有公网IP),当然teamviewer也行(次选,画质低,不需要公网IP)

Windows远程Linux、Unix、MAC系统

首选VNC(需要有公网IP),局域网就不用了;次选teamviewer或者向日葵(不需要公网IP)


MAC远程Windows系统

首选:Microsoft Remote Desktop这款软件(需要有公网IP),软件商城可能无法下载,需要自己到第三方网站下载。次选teamviewer(不需要公网IP)

MAC远程MAC系统

vnc方式(首选,需要有公网IP)

需要在远端的机器的偏好设置---共享中开启屏幕共享,这样就启动了VNC服务端。command+k键打开vnc客户端,输入vnc://192.168.0.135:5899这样的地址进行连接。

回到我的MAC 功能(次选,内网的话首选)

需要在远端的机器的偏好设置---iCloud设置中开启回到我的MAC功能,然后在自己的机子上command+空格搜索屏幕共享,打开软件,输入远端机器的Apple ID、主机名或者IP地址进行连接;如果远端机器上在局域网,直接在Finder的左侧也是可以看到远端机器的(开启了该功能并且设置了显示才能看到),可以直接连接。

Teamviewer或者向日葵

下载安装包,安装后启动就可以使用了。
https://www.teamviewer.com/en/download/mac

MAC远程Linux、Unix系统

vnc方式(首选,需要有公网IP)

command+k键打开vnc客户端,输入vnc://192.168.0.135:5899这样的地址进行连接。

Teamviewer或者向日葵

下载安装包,安装后启动就可以使用了。
https://www.teamviewer.com/en/download/mac
http://sunlogin.oray.com/zh_CN/download/?utm_source=client&utm_medium=redirect&utm_campaign=sl_download


Linux、Unix远程MAC系统

vnc方式(首选,需要有公网IP)

需要在远端的机器的偏好设置---共享中开启屏幕共享,这样就启动了VNC服务端。然后用vnc客户端连接就好了。

Teamviewer或者向日葵

参考本文安装方法安装使用。

Linux、Unix远程Linux、Unix系统

vnc方式(首选,需要有公网IP)

参考本文安装方法安装安装VNC服务端。然后用vnc客户端连接就好了。

Teamviewer或者向日葵

参考本文安装方法安装使用。

Linux、Unix远程Windows系统

vnc方式

需要在windows中安装vnc服务端,启动就能用了。

Teamviewer或者向日葵

下载安装:https://www.teamviewer.com/en/download/windows

rdesktop

官网:http://www.rdesktop.org

wget https://github.com/rdesktop/rdesktop/releases/download/v1.8.3/rdesktop-1.8.3.tar.gz
tar -zxf rdesktop-1.8.3.tar.gz
cd rdesktop-1.8.3
./configure
make && make install

安装完成后输入:rdesktop 192.168.1.135连接。

参考:http://www.centoscn.com/image-text/install/2013/1118/2138.html


文章作者: Leo
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LeoLan的小站
系统管理 vnc服务
喜欢就支持一下吧