35 lines
821 B
Markdown
35 lines
821 B
Markdown
|
# Raspberry Pi 4B Ubuntu 开启 SSH
|
|||
|
|
|||
|
在 Ubuntu 系统下,SSH 服务由 openssh-server 包提供,可使用 APT 命令安装。
|
|||
|
|
|||
|
```bash
|
|||
|
sudo apt install openssh-server
|
|||
|
```
|
|||
|
|
|||
|
安装成功后,编辑 /etc/ssh/sshd_config 文件,开启如下选项,其他保持默认:
|
|||
|
|
|||
|
```bash
|
|||
|
Port 22
|
|||
|
HostKey /etc/ssh/ssh_host_rsa_key
|
|||
|
HostKey /etc/ssh/ssh_host_ecdsa_key
|
|||
|
HostKey /etc/ssh/ssh_host_ed25519_key
|
|||
|
PermitEmptyPasswords no
|
|||
|
UsePAM yes
|
|||
|
TCPKeepAlive yes
|
|||
|
Subsystem sftp internal-sftp
|
|||
|
```
|
|||
|
|
|||
|
配置完毕,可使用如下命令开启/停止 SSH 服务:
|
|||
|
|
|||
|
```bash
|
|||
|
# 启动 SSH 服务
|
|||
|
sudo systemctl start sshd.service
|
|||
|
# 使能 SSH 服务(每次开机后自动启动服务)
|
|||
|
sudo systemctl enable sshd.service
|
|||
|
|
|||
|
# 停止 SSH 服务
|
|||
|
sudo systemctl stop sshd.service
|
|||
|
# 禁能 SSH 服务
|
|||
|
sudo systemctl disable sshd.service
|
|||
|
```
|