SSH Tunnel: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
Line 24: Line 24:


=== Destroy an SSH tunnel ===
=== Destroy an SSH tunnel ===
Find the process id of the ssh tunnel.


<pre>
<pre>
$ps aux | grep [LOCAL_PORT_NUMBER]
$ ps aux | grep [LOCAL_PORT_NUMBER]
</pre>
 
Kill the process of the ssh tunnel.
 
<pre>
$ kill -9 [PID]
</pre>
</pre>



Revision as of 17:32, 28 August 2021

Objective

Create an SSH tunnel on a local machine which redirects MySQL requests to another machine on the LAN.

Establish SSH Tunnel

$ ssh -f user@remote-server.com -L 8888:remote_server.com:3306 -N

[1]

Troubleshooting

View SSH tunnels

$ lsof -i tcp | grep ^ssh

ssh       18250 damien    3u  IPv4 0xf863dcf7cc3dd6d5      0t0  TCP 192.168.123.105:56935->ds920:21098 (ESTABLISHED)
ssh       18250 damien    5u  IPv6 0xf863dcf7ce5b1e1d      0t0  TCP localhost:ddi-tcp-1 (LISTEN)
ssh       18250 damien    6u  IPv4 0xf863dcf7c661454d      0t0  TCP localhost:ddi-tcp-1 (LISTEN)

Destroy an SSH tunnel

Find the process id of the ssh tunnel.

$ ps aux | grep [LOCAL_PORT_NUMBER]

Kill the process of the ssh tunnel.

$ kill -9 [PID]

See Also

Reference