远程连接服务器操作指南
在日常运维或开发工作中,远程连接服务器是高频操作,本文将系统讲解如何通过不同协议(如RDP、SSH)安全高效地远程访问服务器,并附详细步骤与安全建议,以下内容基于主流的Windows与Linux系统,适用于云服务器、本地物理机及虚拟机环境。
进入“Windows Defender 防火墙” → “高级设置” → 添加入站规则,选择“端口” → 输入“3389” → 允许连接。
ipconfig
查看IPv4地址。 mstsc
)。 注意:若使用云服务器,需在云平台安全组中放行3389端口。
sudo apt update && sudo apt install openssh-server -y
sudo yum install openssh-server -y
sudo systemctl start sshd # 启动服务 sudo systemctl enable sshd # 设置开机自启
sudo ufw allow 22/tcp
sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --reload
ssh 用户名@服务器IP
安全建议:
sudo
权限。 ssh-keygen -t rsa -b 4096
ssh-copy-id 用户名@服务器IP
工具推荐:Google Authenticator、Authy。
sudo ufw allow from 192.168.1.100 to any port 22
# Ubuntu/Debian sudo apt update && sudo apt upgrade -y # CentOS/RHEL sudo yum update -y
ping
或traceroute
)。 chmod 600 ~/.ssh/id_rsa
)。 systemctl status sshd
; netstat -tuln | grep 22
。 引用说明
本文参考Microsoft官方文档、OpenSSH手册及AWS/Azure云服务最佳实践,结合运维经验整理,确保内容的准确性与可操作性。