Skip to content

Commit

Permalink
ssh: Add ProxyJump
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Feb 6, 2024
1 parent 08fb921 commit 31ad938
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
26 changes: 26 additions & 0 deletions docs/dev/ssh.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ Host example

`-L``-R``-D` 和配置文件中对应的选项都可以多次出现,指定多条转发规则,它们互相独立、不会覆盖,因此如果重复指定了同一个端口,就会出现冲突。

### 跳板 {#jump-host}

SSH 支持通过跳板机连接目标主机,即先 SSH 登录 jump-host,再从 jump-host 登录目标主机。一些受限的网络环境常常采用这种方案,例如一个集群内只有跳板机暴露在公网上,而其他主机都在被隔离的内网中,只能通过跳板机访问。

`ssh` 命令的 `-J` 选项可以指定跳板机,例如:

```shell
ssh -J [email protected] [email protected]
```

对应的配置文件语句是 `ProxyJump [email protected]`

如果要给跳板机设置更多参数,如端口等,则必须使用配置文件:

```shell
Host jumphost
HostName jumphost.example.com
User jumphostuser
Port 2333
Host realhost
HostName realhost.example.com
User realhostuser
ProxyJump jumphost
```

### 高级功能:连接复用 {#connection-reuse}

SSH 协议允许在一条连接内运行多个 channel,其中每个 channel 可以是一个 shell session、端口转发、scp 命令等。OpenSSH 支持链接复用,即一个 SSH 进程在后台保持连接,其他客户端在连接同一个主机时可以服用这个连接,而不需要重新握手认证等,可以显著减少连接时间。
Expand Down
7 changes: 6 additions & 1 deletion docs/ops/checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

- 如果物理服务器带有 IPMI 等带外管理功能,是否已启用并配置了固定 IP 地址和安全的密码?

## 安全
## 系统安全

- 是否所有用户都(或者至少 root 及有 sudo 权限的用户)具有强密码?
- SSH 的密码登录是否已禁用?(`PasswordAuthentication no`
- 如果有任何原因需要启用密码登录,是否已禁用 root 用户的密码登录?(`PermitRootLogin prohibit-password`
- 或者,仅对有需要的用户启用密码登录?(`Match User <username>``PasswordAuthentication yes`

## 网络安全

- MySQL、PostgreSQL、Redis 等数据库服务是否只监听了本地地址?
- 或者,已经配置了外部防火墙阻断相关端口的入站连接?(MySQL: 3306,PostgreSQL: 5432,Redis: 6379)

0 comments on commit 31ad938

Please sign in to comment.