跳转到内容

SSH 远程连接

本文介绍如何配置和使用 SSH 远程连接你的 EL 服务器。

  • 确认 SSH 服务运行状态
  • 使用密码和密钥登录
  • 基本的 SSH 安全配置

EL 9 默认安装并启用了 OpenSSH 服务:

检查 sshd 状态
$ sudo systemctl status sshd
确认 SSH 端口已开放
$ sudo ss -tlnp | grep :22
基本连接
$ ssh username@server-ip
指定端口
$ ssh -p 2222 username@server-ip

密钥认证比密码更安全,推荐使用:

在客户端生成密钥对
$ ssh-keygen -t ed25519 -C "your-comment"
将公钥复制到服务器
$ ssh-copy-id username@server-ip

验证密钥登录后,可以考虑禁用密码登录。详见SSH 安全配置