CentOS Stream 8 的“远程”通常指远程管理/远程登录,常见方式有 SSH(命令行) 和 远程桌面(图形界面)。下面按最常用场景给你一份清晰、可操作的说明。
CentOS Stream 8 默认一般已安装 openssh-server,如未安装:
dnf install -y openssh-server
启动并设置开机自启:
systemctl enable --now sshd
检查状态:
systemctl status sshd
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
ip addr
或
hostname -I
ssh 用户名@服务器IP
ssh 用户名@服务器IP
编辑配置:
vim /etc/ssh/sshd_config
常见安全配置:
Port 2222
PermitRootLogin no
PasswordAuthentication no
重启 SSH:
systemctl restart sshd
dnf groupinstall -y "Server with GUI"
dnf install -y tigervnc-server
vncpasswd
vncserver :1
使用 RealVNC / TightVNC / Remmina 连接:
服务器IP:1
⚠️ 注意:VNC 默认端口 5901
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) 连接即可。
systemctl enable --now cockpit.socket
firewall-cmd --permanent --add-service=cockpit
firewall-cmd --reload
浏览器访问:
https://服务器IP:9090
# 查看端口是否监听
ss -lntp | grep 22
# 查看防火墙
firewall-cmd --list-all
# SELinux(少见)
getenforce
| 场景 | 推荐 |
|---|---|
| 服务器 | ✅ SSH(必开) |
| 偶尔图形 | XRDP / VNC |
| 管理 | Cockpit |
如果你能具体说明:
我可以直接给你 一步一步量身方案 ✅