.\" Copyright (c) 2021, 2022 Omar Polo .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .Dd $Mdocdate: July 6 2022$ .Dt LSTUN 1 .Os .Sh NAME .Nm lstun .Nd lazy ssh tunnel .Sh SYNOPSIS .Nm .Bk -words .Op Fl dv .Fl B Ar sshaddr .Fl b Ar addr .Op Fl t Ar timeout .Ar destination .Ek .Sh DESCRIPTION .Nm binds the local .Ar addr and lazily spawns an .Xr ssh 1 instance to forward the traffic to a remote end. After .Ar timeout seconds from the last client activity, the ssh tunnel is closed. .Pp The .Xr ssh 1 tunnel is established by running .Bk .Pa ssh .Fl L Ar sshaddr .Fl NTq .Ar destination . .Ek .Pp The arguments are as follows: .Bl -tag -width Ds .It Fl B Xo .Sm off .Oo Ar bind_address : Oc .Ar port : host : hostport .Sm on .Xc Fed to .Xr ssh 1 .Fl L flag. .It Fl b Oo Ar host : Oc Ns Ar port Where to bind the local socket. If not specified, .Ar host defaults to localhost. .It Fl d Do not daemonize. .Nm will run in the foregound and log to .Em stderr . .It Fl t Ar timeout Number of seconds after the last client shutdown to kill the ssh process. Set to zero to keep the tunnel open indefinitely. Defaults to 600 .Pq ten minutes . .It Fl v Produce more verbose output. .El .Sh EXAMPLES Forward traffic on the local port 2525 to the remote port 25 .Po the port 2526 is binded by ssh while .Nm listens on 2525 and forwards the traffic .Pc .Bd -literal -offset indent $ lstun -B 2526:localhost:25 -b 2525 example.com .Ed .Sh SEE ALSO .Xr ssh 1 .Sh AUTHORS .An -nosplit The .Nm utility was written by .An Omar Polo Aq Mt op@omarpolo.com . .Sh CAVEATS Currently it's impossible to pass flags to the .Xr ssh 1 sub command. This is especially painful when you need to use, say, a jump host.