安全、高效地启用和配置 SSH 远程访问
OpenSSH(Open Secure Shell)是一套用于安全远程登录和其他网络服务的工具,它通过加密通信防止窃听、连接劫持等攻击。它是 SSH 协议的开源实现,广泛用于 Linux、macOS 和现代 Windows 系统。
sudo apt update
sudo apt install openssh-server
sudo systemctl start ssh
sudo systemctl enable ssh
sudo systemctl status ssh
22,确保防火墙放行该端口。Windows 10(1809 版本起)和 Windows 11 内置了 OpenSSH 客户端和服务器功能。
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
C:\ProgramData\ssh\sshd_config。/etc/ssh/sshd_config,设置 PermitRootLogin no。sudo systemctl restart ssh(Linux)或 Restart-Service sshd(Windows PowerShell)
Q:无法连接 SSH?
A:检查服务是否运行、防火墙是否放行端口、IP 是否正确。
Q:如何生成 SSH 密钥对?
在客户端运行:
ssh-keygen -t ed25519 -C "your_email@example.com"然后将公钥(
~/.ssh/id_ed25519.pub)内容追加到服务器的 ~/.ssh/authorized_keys 文件中。