Shell Commands
sed
Insert content from file after pattern:
sed -i -e "/pattern/r${file}" target.txt
Replace pattern with content from file:
sed -i -e "/{pattern/r${file}" -e "d}" target.txt
Reverse Tunneling
Definitions:
- WS
- Workstation, connects to the tunnel.
- JS
-
Jump server, can be the same host as WS if directly accessible.
sshd_config
must haveAllowTcpForwarding yes
andGatewayPorts yes
. - RS
- Remote server, establishes the tunnel.
On RS establish the tunnel to JS:
ssh -R <JS port>:<RS iface adress>:<RS port> [<JS user>@]<JS adress> # i.e. for forwarding ssh: ssh -R 2222:0.0.0.0:22 [email protected]
On WS connect to JS, for ssh this may look like:
ssh -F/dev/null -p 2222 [email protected]