PVE主机安装Ubuntu之开启远程桌面&SSH登录

一、开启 SSH 登录

# 检查 SSH 服务状态
systemctl status ssh

# 如果 SSH 服务未启动,使用以下命令启动
systemctl start ssh

# 确保 SSH 服务在开机时自动启动
systemctl enable ssh

二、开启远程桌面

Ubuntu 默认使用 GNOME 桌面环境,开启远程桌面可以使用 VNC 或者 RDP。这里介绍如何使用 xrdp 来配置远程桌面服务。

1、更新包管理器并安装 xrdp

apt update 更新软件包列表
sudo apt upgrade -y 升级已安装的软件包到最新版本
apt install xrdp -y 安装XRDP
1.1、遇到错误
root@ubuntu:~# apt update
Get:1 file:/cdrom jammy InRelease
Ign:1 file:/cdrom jammy InRelease
Get:2 file:/cdrom jammy Release
Err:2 file:/cdrom jammy Release
File not found - /cdrom/dists/jammy/Release (2: No such file or directory)
0% [Connecting to cn.archive.ubuntu.com (2403:2c80:5::6)]
0% [Connecting to cn.archive.ubuntu.com (2403:2c80:5::6)]
1.2、解决方法
//移除CD-ROM源 通过编辑 /etc/apt/sources.list 文件,
//移除或注释掉与 cdrom 相关的行 然后执行apt update
sudo nano /etc/apt/sources.list
//使用清华大学的镜像源:
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
//或者使用官方的 Ubuntu 源:
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

前面加上 # 注释掉
Ctrl + X 退出编辑器 n 不保存 y 保存

//更新软件包列表
sudo apt update

2、安装桌面环境(如果服务器上没有 GUI)

apt install ubuntu-desktop -y
sudo apt install xfce4

3、配置 xrdp 使用默认的 GNOME 桌面环境

//编辑 xrdp 配置文件 XRDP 使用桌面环境
echo "gnome-session" > ~/.xsession
// 重启 xrdp 服务 和 xrdp-sesman 服务
sudo systemctl restart xrdp
sudo systemctl restart xrdp-sesman
4、配置防火墙允许远程桌面连接(如果防火墙开启)
ufw allow 3389/tcp
5、重启服务器
reboot

————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/WIK_7264/article/details/144849362

posted @ 2025-02-19 11:31  通宵敲代码  阅读(1014)  评论(0)    收藏  举报