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 If not specified,
66 .Ar host
67 defaults to localhost.
68 .It Fl d
69 Do not daemonize.
70 .Nm
71 will run in the foregound and log to
72 .Em stderr .
73 .It Fl t Ar timeout
74 Number of seconds after the last client shutdown to kill the ssh
75 process.
76 Set to zero to keep the tunnel open indefinitely.
77 Defaults to 600
78 .Pq ten minutes .
79 .It Fl v
80 Produce more verbose output.
81 .El
82 .Sh EXAMPLES
83 Forward traffic on the local port 2525 to the remote port 25
84 .Po the port 2526 is binded by ssh while
85 .Nm
86 listens on 2525 and forwards the traffic
87 .Pc
88 .Bd -literal -offset indent
89 $ lstun -B 2526:localhost:25 -b 2525 example.com
90 .Ed
91 .Sh SEE ALSO
92 .Xr ssh 1
93 .Sh AUTHORS
94 .An -nosplit
95 The
96 .Nm
97 utility was written by
98 .An Omar Polo Aq Mt op@omarpolo.com .
99 .Sh CAVEATS
100 Currently it's impossible to pass flags to the
101 .Xr ssh 1
102 sub command.
103 This is especially painful when you need to use, say, a jump host.