安全、高效地使用 SSH 远程管理你的服务器
OpenSSH Server(openssh-server)是 OpenSSH 套件中的服务端组件,用于提供安全的远程登录、文件传输和其他网络服务。
它基于 SSH(Secure Shell)协议,通过加密通信防止窃听、连接劫持等攻击,是 Linux/Unix 系统中最常用的远程管理工具。
在大多数 Linux 发行版中,可通过包管理器安装:
sudo apt update && sudo apt install openssh-server
sudo dnf install openssh-server
安装完成后,服务通常会自动启动。
主配置文件位于:/etc/ssh/sshd_config
常用操作命令:
# 启动服务
sudo systemctl start sshd
# 设置开机自启
sudo systemctl enable sshd
# 重启服务(修改配置后)
sudo systemctl restart sshd
# 查看状态
sudo systemctl status sshd
PermitRootLogin noAllowUsers alice bobPasswordAuthentication no修改配置后务必测试连接,避免被锁在服务器外!
~/.ssh 目录权限为 700,私钥为 600。sudo journalctl -u sshd 或 /var/log/auth.log
- OpenSSH 官方网站
- sshd_config 手册页
- 《SSH Mastery》书籍(Michael W. Lucas 著)