温馨提示×

centos stream8怎么远程

小樊
44
2026-07-20 05:03:00
栏目: 智能运维

CentOS Stream 8 的“远程”通常指远程管理/远程登录,常见方式有 SSH(命令行)远程桌面(图形界面)。下面按最常用场景给你一份清晰、可操作的说明。


一、远程 SSH(最推荐,服务器必开)

1️⃣ 安装并启动 SSH 服务

CentOS Stream 8 默认一般已安装 openssh-server,如未安装:

dnf install -y openssh-server

启动并设置开机自启:

systemctl enable --now sshd

检查状态:

systemctl status sshd

2️⃣ 放行防火墙端口(22)

firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload

3️⃣ 查看服务器 IP

ip addr

hostname -I

4️⃣ 从客户端远程连接

Linux / macOS

ssh 用户名@服务器IP

Windows

  • 推荐:使用 PowerShell / Windows Terminal
ssh 用户名@服务器IP
  • 或使用 Xshell / MobaXterm / PuTTY

5️⃣(可选)修改 SSH 端口 / 禁止 root 登录

编辑配置:

vim /etc/ssh/sshd_config

常见安全配置:

Port 2222
PermitRootLogin no
PasswordAuthentication no

重启 SSH:

systemctl restart sshd

二、远程桌面(图形界面)

方式一:VNC(最常用)

1️⃣ 安装桌面环境(如未安装)

dnf groupinstall -y "Server with GUI"

2️⃣ 安装 VNC Server

dnf install -y tigervnc-server

3️⃣ 设置 VNC 密码

vncpasswd

4️⃣ 启动 VNC

vncserver :1

5️⃣ 客户端连接

使用 RealVNC / TightVNC / Remmina 连接:

服务器IP:1

⚠️ 注意:VNC 默认端口 5901


方式二:XRDP(Windows 远程桌面)

dnf install -y epel-release
dnf install -y xrdp
systemctl enable --now xrdp
firewall-cmd --permanent --add-port=3389/tcp
firewall-cmd --reload

然后用 Windows 远程桌面连接(mstsc) 连接即可。


三、远程管理(Web 面板,可选)

Cockpit(CentOS 自带)

systemctl enable --now cockpit.socket
firewall-cmd --permanent --add-service=cockpit
firewall-cmd --reload

浏览器访问:

https://服务器IP:9090

四、常见问题排查

❌ SSH 连不上

# 查看端口是否监听
ss -lntp | grep 22

# 查看防火墙
firewall-cmd --list-all

# SELinux(少见)
getenforce

❌ 云服务器连不上

  • 检查 安全组 / 防火墙
  • 确保放行 22 / 3389 / 5901

五、推荐组合(直接照着用)

场景 推荐
服务器 ✅ SSH(必开)
偶尔图形 XRDP / VNC
管理 Cockpit

如果你能具体说明:

  • 物理机 / 云服务器
  • 只要命令行还是要桌面
  • Windows 还是 Linux 客户端

我可以直接给你 一步一步量身方案

0