Files
nexus/wiki/sources/Ubuntu-24.04-enable-SSH.md

52 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Ubuntu 24.04 启用 SSH 服务"
type: source
tags: [ssh, ubuntu, server]
date: 2025-03-16
---
## Source File
- [[raw/Home Office/Ubuntu 24.04 enable SSH.md]]
## Summary
- 核心主题Ubuntu 24.04 启用 OpenSSH Server 的完整步骤
- 问题域Ubuntu 24.04 改变 SSH 服务激活机制(默认 socket activation与传统方式不同
- 方法/机制:安装 openssh-server → systemctl enable/start ssh → 配置 UFW 防火墙 → 远程连接验证
- 结论/价值Ubuntu 24.04 使用 ssh.socket 代替 ssh.service管理员需注意新管理方式
## Key Claims
- Ubuntu 24.04 默认使用 ssh.socket 激活机制:有连接进入时才启动 sshd非传统常驻进程模式
- 安装命令:`sudo apt update && sudo apt install openssh-server -y`
- 启动并开机自启:`sudo systemctl start ssh && sudo systemctl enable ssh`
- 检查 socket 状态:`sudo systemctl status ssh.socket`(监听状态显示 `ListenStream=22`
- 防火墙允许 SSH`sudo ufw allow ssh``sudo ufw allow 22/tcp`
- 验证服务状态:`sudo systemctl status ssh`,显示 `active (running)` 或 socket 模式 `ListenStream=22`
- 切换回传统常驻模式:`sudo systemctl disable --now ssh.socket && sudo systemctl enable --now ssh.service`
- Ubuntu 24.04 修改监听端口推荐通过 `systemctl edit ssh.socket` 而非仅修改 `/etc/ssh/sshd_config`
## Key Quotes
> "Ubuntu 24.04 引入了一个重要的变化:默认使用 `ssh.socket` 激活机制(即只有在连接请求进入时才启动 SSH 守护进程)" — 与旧版本最大差异
## Key Concepts
- [[SSH Socket Activation]]Ubuntu 24.04 默认机制sshd 按需启动而非常驻,节省资源
- [[UFW 防火墙规则]]Ubuntu 默认防火墙,通过 `ufw allow ssh` 放行 22 端口
- [[SSH 服务管理]]`systemctl start/enable/disable` 管理 ssh.service 或 ssh.socket
- [[OpenSSH Server]]Ubuntu SSH 服务端实现,包名 `openssh-server`
## Key Entities
- [[Ubuntu 24.04]]2024 年 4 月发布的 LTS 版本SSH 管理机制变化
- [[OpenSSH]]:开源 SSH 协议实现Ubuntu 默认 SSH 服务端
## Connections
- [[SSH Socket Activation]] ← default_in ← [[Ubuntu 24.04]]
- [[OpenSSH Server]] ← installed_by ← [[apt install openssh-server]]
- [[UFW 防火墙规则]] ← must_configure ← [[SSH 服务管理]]
## Contradictions
- 旧版 Ubuntu< 24.04)管理方式:通过 `/etc/ssh/sshd_config` 修改端口后 `systemctl restart sshd`24.04 推荐 `systemctl edit ssh.socket`
## Metadata
- 作者shenwei
- 创建时间2025-03-16
- 原始标签:[ssh, ubuntu]