Ubuntu SSH远程桌面连接主要有两种方式:命令行转发图形界面和使用专用工具。以下是具体步骤:
安装必要软件
确保SSH服务端和客户端已安装:
sudo apt update sudo apt install openssh-server openssh-client xauth # 服务端需安装xauth 配置SSH服务端
编辑配置文件 /etc/ssh/sshd_config,启用X11转发:
X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes 重启SSH服务:
sudo systemctl restart ssh 客户端连接
使用SSH命令时添加 -X 参数启用转发:
ssh -X username@remote_ip 连接成功后,可在终端中启动图形应用(如 gedit、firefox),界面会显示在本地机器。
sudo apt install tightvncserver vncserver # 首次运行需设置密码 :1 对应端口5901)和密码即可。sudo apt install xrdp sudo ufw allow 3389 # 开放防火墙端口 sudo systemctl enable --now xrdp sudo apt install ubuntu-desktop 安装。