SSH
SSH, Common, Web and more
Syntax
ssh -L [bind_address:]local_port:target_host:target_port [user@]ssh_server
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
-L |
ssh -L 3307:localhost:3306 user@host |
Common | |
-N |
command | ssh -NL 8080:internal:80 user@host |
Common |
-f |
ssh -fNL 8080:internal:80 user@host |
Common | |
bind_address |
( 127.0.0.1) | ssh -L 0.0.0.0:8080:internal:80 user@host |
Advanced |
-g |
ssh -gL 8080:internal:80 user@host |
Advanced |
Examples
MySQL
ssh -NL 3307:localhost:3306 user@db-server # : mysql -h 127.0.0.1 -P 3307 -u dbuser -p
localhost db-server, db-server 3306
Web
ssh -NL 8080:internal-web.corp:80 user@bastion
Web, http://localhost:8080
Redis
ssh -fNL 6380:redis.internal:6379 user@gateway
, redis-cli -p 6380 Redis
ssh -NL 3307:db:3306 -L 6380:redis:6379 -L 8080:web:80 user@bastion
command
Common Errors
bind: Address already in use, lsof -i : ss -tlnp | grep,
channel 2: open failed: connect failed: Connection refusedSSH :,
Tips
- : -L :, """"
- SSH, localhost SSH
- autossh -M 0 ssh