# Help me create a cool 'pv' monitor of an ssh tunnel

## dkasak

Hi all. This should be easy, but I can't quite make it work.

I regularly set up an ssh tunnel for database traffic to remote servers, eg:

```
ssh -CL 15432:127.0.0.1:5432 remote.db
```

What I want to do is forward DB traffic through 'pv', so I can get a nice graphical representation of traffic flowing. I've tried:

```
nc -l -p 10000 | pv -b | nc -l -p 11000

ssh -CL 11000:127.0.0.1:5432 remote.db

```

 ... but it seems that 'nc' binds to the port, and ssh can't get hold of it. I'm not sure if there is a way of telling 'nc' to connect to a port without binding to it? So anyway, I next tried:

```
nc -l -p 10000 | pv -b | socat - TCP4:127.0.0.1:11000

ssh -CL 11000:127.0.0.1:5432 remote.db

```

 ... and this at least doesn't give any errors, but it also doesn't work. What's the easiest way of achieving what I'm trying to do?

----------

## toralf

 *dkasak wrote:*   

> 
> 
> ```
> ssh -CL 15432:127.0.0.1:5432 remote.db
> ```
> ...

 Maybe OT, but :

```
 -C      Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11,

             TCP and UNIX-domain connections).  The compression algorithm is the same used by gzip(1), and

             the “level” can be controlled by the CompressionLevel option for protocol version 1.  Compres‐

             sion is desirable on modem lines and other slow connections, but will only slow down things on

             fast networks.  The default value can be set on a host-by-host basis in the configuration files;

             see the Compression option.

```

 furthermore compression lowers cryptographic security IIRC.

----------

## dkasak

Yes I've found that using compression speeds things up a LOT on my high-speed copper ADSL2 line. Australia doesn't believe in fast internet.

----------

