DC娱乐网

Ubuntu Server 开启 SSH 服务(最简步骤) 1. 安装 SS

Ubuntu Server 开启 SSH 服务(最简步骤)

1. 安装 SSH 服务(系统默认一般没装)

bash

sudo apt update
sudo apt install openssh-server -y
 

2. 查看 SSH 状态

bash

systemctl status ssh
 

显示 active (running) 即为正常运行。

3. 开机自启(必开,重启不失效)

bash

sudo systemctl enable ssh
 

4. 常用启停命令

- 重启 SSH: sudo systemctl restart ssh 
- 关闭 SSH: sudo systemctl stop ssh 
- 禁止开机自启: sudo systemctl disable ssh 

5. 连接测试

本机查看服务器 IP:

bash

ip a
 

客户端使用工具(Xshell、FinalShell、Putty)连接:
 ssh 用户名@服务器IP 

 

防火墙放行(Ubuntu 默认 ufw 防火墙)

如果连不上,放行 SSH 端口:

bash

sudo ufw allow 22/tcp
sudo ufw reload