使用VNC在Windows上远程访问Ubuntu服务器

随笔1天前发布 心语
4 0 0

Step 0:事前准备

一台安装了ghome桌面的Ubuntu服务器(用作server)
一台Windows机器(用作client)

Step 1:Linux服务器

在Ubuntu上安装一个VNC服务器,有多个选择,此处选用tigervnc,使用apt命令即可直接安装发行版。

apt install tigervnc

安装完成后可以尝试做以下设置:

vncpasswd
vncserver -geometry 1440x932 #分辨率可按需修改

此时可能暂时无法连接,可以在~/.vnc路径下查看对应的log文件作为日志,其中有相应的报错信息。

如果日志中报错:xrdb: No such file or directory xrdb: can't open file '/homes/${USER}/.Xresources' Terminated

说明在用户目录下缺少.Xresources这一文件,需要手动创建。

将“文件中的内容设置为以下内容:

*background: #000000
*foreground: #FFFFFF

修改VNC的配置文件~/.vnc/xstartup替换如下:

引用自:https://blog.csdn.net/weixin_43714336/article/details/109578971

#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

#gnome-terminal &

sesion-manager & xfdesktop & xfce4-panel &
xfce4-menu-plugin &
xfsettingsd &
xfconfd &
xfwm4 &

此后,将先前未连接成功的vnc server kill掉,示例如:vncserver -kill :1

再次启动一个新的vnc server:

vncserver -geometry 1440x932

记住此时创建的VNC server监听的端口号,如果忘记,可以查看~/.vnc/*.log文件,其中记录了开放监听的TCP端口号。

至此,Linux上的VNC server配置完成。

Step 2:Windows RealVNC Viewer

在Windows系统上下载软件RealVNC Viewer,个人用户可以直接免费使用(企业版需要付费)

使用IP/域名:端口号的格式连接远端server,密码为先前设置的VNC password。

参考:

https://blog.csdn.net/weixin_43714336/article/details/109578971

https://juejin.cn/s/vnc xrdb can't open file '%2Froot%2F.xresources'

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...