VPS如何部署SSH服务?_详细步骤与安全配置指南
如何在VPS上部署SSH服务?
| 步骤 | 操作说明 | 注意事项 |
|---|---|---|
| 1 | 登录VPS系统 | 确保拥有root权限 |
| 2 | 安装OpenSSH | 使用系统包管理器(如apt/yum) |
| 3 | 配置sshdconfig | 修改默认端口、禁用root登录等 |
| 4 | 启动SSH服务 | 使用systemctl命令 |
| 5 | 设置防火墙 | 放行SSH端口 |
VPS如何部署SSH服务?详细步骤与安全配置指南
SSH(Secure Shell)是远程管理VPS的重要工具,本文将详细介绍在主流Linux系统上部署SSH服务的完整流程,并包含关键安全配置建议。一、SSH服务安装与基础配置
1. 安装OpenSSH服务器- 对于Debian/Ubuntu系统:
sudo apt update && sudo apt install openssh-server - 对于CentOS/RHEL系统:
sudo yum install openssh-server
- 启动服务:
sudo systemctl start sshd - 设置开机自启:
sudo systemctl enable sshd - 检查状态:
sudo systemctl status sshd
二、关键安全配置步骤
- 修改默认配置文件
/etc/ssh/sshdconfig文件,建议修改以下参数:
- Port 22 → 改为非标准端口(如2222)
- PermitRootLogin no → 禁止root直接登录
- PasswordAuthentication no → 启用密钥认证
- 配置防火墙规则
- Ubuntu(UFW):
sudo ufw allow 2222/tcp - CentOS(firewalld):
sudo firewall-cmd --add-port=2222/tcp --permanent
- 重启服务使配置生效
sudo systemctl restart sshd
发表评论