在 Ubuntu 上重启 SSH 服务,常用以下方式(取决于系统版本和服务管理方式):
sudo systemctl restart ssh
或(某些老版本包名是 sshd):
sudo systemctl restart sshd
查看状态:
sudo systemctl status ssh
sudo service ssh restart
sudo /etc/init.d/ssh restart
sudo apt update
sudo apt install openssh-server
sudo systemctl enable --now ssh
ssh,不是 sshd/etc/ssh/sshd_config 后需要重启才生效如果你是想重置 SSH 连接/会话或修复无法登录问题,可以告诉我具体场景。