版权声明:本文为博主原创文章,可以自由转载。 https://blog.csdn.net/u010953692/article/details/84979965
ubuntu 安装 VNC
1,ubuntu 安装 VNC
- ubuntu系统版本
# cat /etc/issue
Ubuntu 16.04 LTS \n \l
- tightvncserver安装
# apt-cache search tightvncserver
tightvncserver - virtual network computing server software
tightvnc-java - TightVNC java applet and command line program
# apt-get install -y tightvnserver
# apt-get install -y xfce4 xfce4-goodies
2,VNC配置
- VNC设置密码
# vncserver
You will require a password to access your desktops.
Password:
- 选择N
Would you like to enter a view-only password (y/n)? n
- 关闭VNC服务
# ps aux | grep vnc
root 14031 0.0 0.3 14904 6448 ? S 12月12 0:00 Xtightvnc :1
root 16565 0.0 0.2 8164 4952 ? S 12月12 0:00 Xtightvnc :2
# vncserver -kill :1
Killing Xtightvnc process ID 14031
# vncserver -kill :2
Killing Xtightvnc process ID 16565
- 修改VNC配置文件添加
startxfce4 &
# vim .vnc/xstartup
#!/bin/sh
#/etc/X11/Xresources/x11-common
xrdb $HOME/.Xresources
startxfce4 &
- 运行VNC
# vncserver
New 'X' desktop is ubuntu:1
3,macOS VNC Viewer 安装
- VNC连接
- 连接成功,但不是实时画面
4,安装xrdp
# apt-get install -y xrdp
# apt-cache search vnc4server
vnc4server - Virtual network computing server software
# apt-get install -y vnc4server
# /etc/init.d/xrdp restart
[ ok ] Restarting xrdp (via systemctl): xrdp.service.
5,macOS 使用Microsoft Remote Desktop 连接ubuntu
- Microsoft Remote Desktop百度网盘地址
链接:https://pan.baidu.com/s/1pUrgIL1i8MC1Ax2cL_1BcQ 密码:5lib
- 连接成功 没有背景
# apt-get install -y xubuntu-desktop
# reboot
# pwd
/root
# touch .xsession
# chmod 775 .xsession
# echo xfce4-session > .xsession
# cat .xsession
xfce4-session
# vim /etc/xrdp/startwm.sh
#!/bin/sh
if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG LANGUAGE
fi
xfce4-session
. /etc/X11/Xsession
# /etc/init.d/xrdp restart
[ ok ] Restarting xrdp (via systemctl): xrdp.service.
6,安装teamviewer实时控制桌面
# apt-cache search teamviewer
teamviewer - Remote control and meeting solution
# apt-get install -y teamviewer
7,x11vnc 安装,实时远程桌面
- 安装 x11vnc
# apt-cache search x11vnc
# apt-get install -y x11vnc
# x11vnc -storepasswd
# cd /lib//systemd/system
# touch x11vnc.service
# chmod 775 x11vnc.service
# vim /lib/systemd/system/x11vnc.service
[Unit]
Description=Start x11vnc at startup.
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /root/.vnc/passwd -rfbport 5901 -shared
[Install]
WantedBy=multi-user.target
- 运行 x11vnc
# systemctl daemon-reload
# systemctl start x11vnc.service
# systemctl status x11vnc.service
# systemctl enable x11vnc.service
- x11vnc 运行报错
# x11vnc
XOpenDisplay("") failed.
- 更新软件和系统
# apt-get update && apt-get upgrade && apt-get dist-upgrade
- 升级gnome
# apt-get install -y gnome-shell ubuntu-gnome-desktop
# gnome-shell --version
GNOME Shell 3.18.5
- 在本机运行x11vnc,使用其它主机ssh远程访问运行x11vnc会报错
XOpenDisplay("") failed.
- 使用vnc viewer 连接 X11vnc
# systemctl status x11vnc
● x11vnc.service - Start x11vnc at startup.
Loaded: loaded (/lib/systemd/system/x11vnc.service; enabled; vendor preset: enabled)
Active: active (running) since 日 2018-12-16 11:44:45 CST; 1min 28s ago
Main PID: 5244 (x11vnc)
CGroup: /system.slice/x11vnc.service
├─5244 /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /root/.vnc/passwd -rfbport 5901 -shared
└─5249 /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /root/.vnc/passwd -rfbport 5901 -shared
-
使用 frp + x11vnc 替代 teamviewer
-
frp 安装
内网穿透 frp,ssh远程访问内网 -
修改frpc.ini 转发5901端口到VPS服务器
# vim frpc.ini
[x11vnc]
type = tcp
local_ip = 127.0.0.1
local_port = 5901
remote_port = 5901
- 远程连接X11vnc ,服务器ip:5901
问题:有2个画面,分辨率不对
参考: