lab/note/资源/DevOps/Linux/常用命令.md
张育新 be711334fb docs(note): 添加笔记目录及 gitignore 规则
- 新增 note 目录包含 AI、SQL、Golang、网络等多领域学习笔记
- 更新 .gitignore 添加 note/assets/ 和 note/项目/ 忽略规则
2026-07-10 09:24:40 +08:00

24 lines
720 B
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.

### SSH
#### 快速连接服务器
在ssh的配置文件`~/.ssh/config`中可以设置常用的服务配置,这样就可以直接使用`ssh myserver`快速连接服务器了
```
Host myserver
HostName your-server.com
Port 2222
User ubuntu
IdentityFile ~/.ssh/mykey
```
#### 本地转发
```bash
# 使用示例
ssh -L 25432:localhost:5432 ubuntu@your-server.com
```
**作用**以本地端口25432请求远程服务器在远程服务器看来这是以远程`localhost:5432`发起的请求
**使用场景**当远程服务器某服务限制了只接收远程服务器的127.0.0.1连接,这时候又需要远程连接这个服务,这样的话就能和访问本地服务一样访问了