Blob


1 .\" Copyright (c) 2021, 2022 Omar Polo <op@omarpolo.com>
2 .\"
3 .\" Permission to use, copy, modify, and distribute this software for any
4 .\" purpose with or without fee is hereby granted, provided that the above
5 .\" copyright notice and this permission notice appear in all copies.
6 .\"
7 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 .Dd $Mdocdate: July 6 2022$
15 .Dt LSTUN 1
16 .Os
17 .Sh NAME
18 .Nm lstun
19 .Nd lazy ssh tunnel
20 .Sh SYNOPSIS
21 .Nm
22 .Bk -words
23 .Op Fl dv
24 .Fl B Ar sshaddr
25 .Fl b Ar addr
26 .Op Fl t Ar timeout
27 .Ar destination
28 .Ek
29 .Sh DESCRIPTION
30 .Nm
31 binds the local
32 .Ar addr
33 and lazily spawns an
34 .Xr ssh 1
35 instance to forward the traffic to a remote end.
36 After
37 .Ar timeout
38 seconds
39 from the last client activity, the ssh tunnel is closed.
40 .Pp
41 The
42 .Xr ssh 1
43 tunnel is established by running
44 .Bk
45 .Pa ssh
46 .Fl L Ar sshaddr
47 .Fl NTq
48 .Ar destination .
49 .Ek
50 .Pp
51 The arguments are as follows:
52 .Bl -tag -width Ds
53 .It Fl B Xo
54 .Sm off
55 .Oo Ar bind_address : Oc
56 .Ar port : host : hostport
57 .Sm on
58 .Xc
59 Fed to
60 .Xr ssh 1
61 .Fl L
62 flag.
63 .It Fl b Oo Ar host : Oc Ns Ar port
64 Where to bind the local socket.
65 .It Fl d
66 Do not daemonize.
67 .Nm
68 will run in the foregound and log to
69 .Em stderr .
70 .It Fl t Ar timeout
71 Number of seconds after the last client shutdown to kill the ssh
72 process.
73 Set to zero to keep the tunnel open indefinitely.
74 Defaults to 600
75 .Pq ten minutes .
76 .It Fl v
77 Produce more verbose output.
78 .El
79 .Sh EXAMPLES
80 Forward traffic on the local port 2525 to the remote port 25
81 .Po the port 2526 is binded by ssh while
82 .Nm
83 listens on 2525 and forwards the traffic
84 .Pc
85 .Bd -literal -offset indent
86 $ lstun -B 2526:localhost:25 -b 2525 example.com
87 .Ed
88 .Sh SEE ALSO
89 .Xr ssh 1
90 .Sh AUTHORS
91 .An -nosplit
92 The
93 .Nm
94 utility was written by
95 .An Omar Polo Aq Mt op@omarpolo.com .
96 .Sh CAVEATS
97 Currently it's impossible to pass flags to the
98 .Xr ssh 1
99 sub command.
100 This is especially painful when you need to use, say, a jump host.