在Ubuntu上开启SSH远程登录:完整指南

一、开启SSH远程登录(最常用)

1. 安装OpenSSH服务器

sudo apt update
sudo apt install openssh-server

2. 启动SSH服务


sudo systemctl start ssh
sudo systemctl enable ssh  # 设置开机自启

3. 检查服务状态


sudo systemctl status ssh

4. 配置防火墙(如果启用了UFW)


sudo ufw allow ssh  # 或 sudo ufw allow 22
sudo ufw enable     # 如果还没启用防火墙
sudo ufw status     # 查看规则

5. 连接到远程Ubuntu

从客户端使用:

ssh username@服务器IP地址
# 例如:ssh zhangsan@192.168.1.100

留下你的评论

*