2026-04-02 23:12:36 +08:00

51 lines
849 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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配置ssh和sftp
createTime: 2021/09/28
tags:
- Ubuntu
categories:
- 随记
---
## 安装
**ssh 是客户端sshd 才是服务端**
**2023-6-20 Update**: 在 Ubuntu22.04.2 中包名已经更新为`openssh-clien`, `openssh-server`, `openssh-sftp-server`
```bash
# 查看是否已经安装
dpkg -l | grep ssh
# 安装openssh server
sudo apt install openssh-server
```
## 修改端口
```bash
# 修改端口
sudo vi /etc/ssh/sshd_config
# 修改Port后的参数
# 重启ssh
sudo service ssh restart
```
- **远程连接**
```bash
ssh -p 修改后的端口 用户名@ip地址
```
## 配置 sftp
```bash
# 使用系统自带的internal-sftp服务
sudo vi /etc/ssh/sshd_config
# 修改以下字段
Subsystem sftp internal-sftp
# 限定用户
Match Group sftp
# 更改登录后默认路径
ChrootDirectory /
```