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 HostName User ForwardX11 yes ForwardX11Trusted yes ForwardAgent yes 可以尝试ssh
- 如果已经有桌面、但需要远程访问桌面:
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,输入地址
在服务器上跑:
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. 待补充