Ubuntu 远程桌面

Ubuntu 远程桌面

Posted by Kyon-H on December 12, 2024

1. VNCServer远程桌面

安装gnome-session和vnc服务端

1
2
3
4
5
6
7
8
9
sudo apt install gnome-session-flashback
sudo apt install tigervnc-standalone-server

# 创建xstartup文件
mkdir ~/.vnc/
vim ~/.vnc/xstartup

# 添加执行权限
chmod +x ~/.vnc/xstartup

xstartup内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XKL_XMODMAP_DISABLE=1
export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME"
export XDG_MENU_PREFIX="gnome-flashback-"
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
# 窗口参数设置
xsetroot -solid grey
# 运行复制粘贴
vncconfig -iconic &

gnome-terminal &
# 打开文件管理器
nautils &

# Start GNOME Flashback session in the foreground
#gnome-session --session=gnome-flashback-metacity --disable-acceleration-check &
exec dbus-launch --exit-with-session gnome-session --session=gnome-flashback-metacity --disable-acceleration-check

启动vnc服务端

1
2
3
4
# 启动并获取端口号
vncserver && vncserver -list
# 允许非本地连接
vncserver :1 -localhost no

重置密码

1
2
3
vncpasswd
新密码
再次输入

设置开机自启

创建vncserver_start启动脚本

1
vim /etc/init.d/vncserver_start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
export USER='load' #自定义
eval cd ~$USER
 
case "$1" in
    start)
         su $USER -c '/usr/bin/vncserver -localhost no' #自定义
         echo "Starting VNC server for $USER "
         ;;
    stop)
 
         su $USER -c '/usr/bin/vncserver -kill :1'
         echo "vncserver stopped"
         ;;
    *)
         echo "Usage: /etc/init.d/vncserver {start|stop}"
         exit 1
         ;;
esac
exit 0

给文件加权限

1
2
3
4
5
chmod 777 /etc/init.d/vncserver_start
update-rc.d vncserver_start defaults
#重载服务
systemctl daemon-reload
systemctl enable vncserver_start.service

2. SunShine+Moonlight 串流

必须要有独立显卡,安装cuda

Releases · LizardByte/Sunshine

默认端口:47990

安装虚拟显示器

win远程桌面连接无显示器Ubuntu(22.04.1 LTS)_ubuntu 22.04 虚拟显示器-CSDN博客

Ubuntu20.04 虚拟显示器配置(解决无显示器远程黑屏问题)-腾讯云

1
2
sudo apt install xserver-xorg-core-hwe-18.04
sudo apt install xserver-xorg-video-dummy

配置文件

vim /usr/share/X11/xorg.conf.d/xorg.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Section "Monitor"
  Identifier "Monitor0"
  HorizSync 28.0-80.0
  VertRefresh 48.0-75.0
  Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection
Section "Device"
  Identifier "Card0"
  Driver "dummy"
  VideoRam 256000
EndSection
Section "Screen"
  DefaultDepth 24
  Identifier "Screen0"
  Device "Card0"
  Monitor "Monitor0"
  SubSection "Display"
    Depth 24
    Modes "1920x1080_60.00"
  EndSubSection
EndSection

最后重启

恢复显示器显示

ubtunu开机黑屏无桌面解决方法_ubtun 待机黑屏-CSDN博客

开机打印信息时 Ctrl+Alt+F1 (按住ctrl和alt连续按f1)进入登陆界面(字体格式会发生变化,变细),Ctrl+Alt+F3 (按住ctrl和alt连续按f3)进入tty界面登录

开机打印信息时 Ctrl+Alt+F3 进入命令行登陆界面

1
2
sudo rm /usr/share/X11/xorg.conf.d/xorg.conf
sudo reboot

Moonlight 配置

moonlight按win键没反应解决办法_moonlight win键