24 lines
720 B
Markdown
24 lines
720 B
Markdown
### 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连接,这时候又需要远程连接这个服务,这样的话就能和访问本地服务一样访问了 |