云计算百科
云计算领域专业知识百科平台

服务器图形化显示:x11vnc配置简明教程暨踩坑记

配置x11:一个远程的图形化传输协议

在服务器上:

sudo vim /etc/ssh/sshd_config

修改配置:

AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

重启sshd service

sudo service sshd restart

 在本地:

设置~/.ssh/config

Host <host_name>
HostName <ip>
User <user_name>
ForwardX11 yes
ForwardX11Trusted yes
ForwardAgent yes

测试:

可以尝试ssh <host_name>看能否连接到远程

配置x11vnc:一个传输的客服端

– 如果已经有桌面、但需要远程访问桌面:

在服务器上:

1. 安装x11vnc以及必要dependency

sudo apt-get install x11vnc net-tools

2. 运行x11vnc 

x11vnc -display $DISPLAY -rfbport 5900

– 如果没有桌面,那么需要自己建一个虚拟桌面

在服务器上:

1. 安装x11vnc以及必要dependency

sudo apt-get install x11vnc net-tools xvfb fluxbox

2. 设置$DISPLAY参数

export DISPLAY=:7 # 可以为其他数,just an example

# 为了之后的方便可以写入~/.bashrc中
echo export DISPLAY=:7 >> ~/.bashrc
source ~/.bashrc

3. 新建虚拟桌面

Xvfb $DISPLAY -screen 0 1920x1080x24 &
fluxbox &

4. 运行x11vnc

x11vnc -display $DISPLAY -rfbport 5900

在本地上:

通过real vnc 安装VNC Reviewer,输入地址<ip>:5900 访问

测试:

在服务器上跑:

xeyes

应该能在real vnc中看到两只眼睛👀

常见问题:

1. $DISPLAY已经被使用,或者曾经被使用过

$ Xvfb $DISPLAY -screen 0 1920x1080x24
(EE)
Fatal server error:
(EE) Server is already active for display 7
If this server is no longer running, remove /tmp/.X7-lock
and start again.
(EE)

设置$DISPLAY为其他值或者删掉/tmp/.X7-lock

rm /tmp/.X7-lock

2. x server已在运行

$ Xvfb $DISPLAY -screen 0 1920x1080x24
_XSERVTransSocketUNIXCreateListener: …SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets – Make sure an X server isn't already running(EE)

删掉已有的进程

$ ps -aux | grep Xvfb
user 485583 0.0 0.1 213840 71628 pts/23 S+ 19:52 0:00 Xvfb :4 -screen 0 1920x1080x24
user 506709 0.0 0.0 12628 2304 pts/2 S+ 20:09 0:00 grep –color=auto Xvfb

$ kill -9 485583

3. 待补充

赞(0)
未经允许不得转载:网硕互联帮助中心 » 服务器图形化显示:x11vnc配置简明教程暨踩坑记
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!