lsh.texinfo 45.7 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
3
4
5
6
7
\input texinfo          @c -*-texinfo-*-

@c %**start of header
@setfilename lsh.info
@settitle lsh
@c %**end of header

8
9
@set UPDATED-FOR 0.9.14

Niels Möller's avatar
Niels Möller committed
10
@ifinfo
11
12
Draft manual for LSH. This manual corresponds to @command{lsh} version
@value{UPDATED-FOR}. 
Niels Möller's avatar
Niels Möller committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

Copyright 2000 Niels Möller.

Permission is granted to make and distribute verbatim
copies of this manual provided the copyright notice and
this permission notice are preserved on all copies.

@ignore
Permission is granted to process this file through TeX
and print the results, provided the printed document
carries a copying permission notice identical to this
one except for the removal of this paragraph (this
paragraph not being relevant to the printed manual).

@end ignore
Permission is granted to copy and distribute modified
versions of this manual under the conditions for
verbatim copying, provided also that the sections
entitled ``Copying'' and ``GNU General Public License''
are included exactly as in the original, and provided
that the entire resulting derived work is distributed
under the terms of a permission notice identical to this
one.

Permission is granted to copy and distribute
translations of this manual into another language,
under the above conditions for modified versions,
except that this permission notice may be stated in a
translation approved by the Free Software Foundation.

@end ifinfo

@titlepage
@sp 10
47
48
49
50
@c @center @titlefont{LSH Manual}

@title LSH Manual
@subtitle For @command{lsh} version @value{UPDATED-FOR}
Niels Möller's avatar
Niels Möller committed
51

52
@author Niels Möller
Niels Möller's avatar
Niels Möller committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

@c The following two commands start the copyright page.
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 2000 Niels Möller.

Permission is granted to make and distribute verbatim
copies of this manual provided the copyright notice and
this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified
versions of this manual under the conditions for
verbatim copying, provided also that the sections
entitled ``Copying'' and ``GNU General Public License''
are included exactly as in the original, and provided
that the entire resulting derived work is distributed
under the terms of a permission notice identical to this
one.

Permission is granted to copy and distribute
translations of this manual into another language,
under the above conditions for modified versions,
except that this permission notice may be stated in a
translation approved by the Free Software Foundation.

@end titlepage

80
@node     Top, Introduction, (dir), (dir)
Niels Möller's avatar
Niels Möller committed
81
@comment  node-name,  next,  previous,  up
82
@top
83

84
85
86
87
88
This document describes @command{lsh} and related programs. @command{lsh} suit
of programs is intended as a free replacement for the @command{ssh} suit of
programs. In turn, @command{ssh} was intended as a secure replacement for
the @command{rsh} and @command{rlogin} programs for remote login over the
Internet.
Niels Möller's avatar
Niels Möller committed
89

90
@command{lsh} is a component of the @acronym{GNU} system.
91

92
93
This manual explains how to use and hack @command{lsh}; it corresponds to
@command{lsh} version @value{UPDATED-FOR}.
Niels Möller's avatar
Niels Möller committed
94

95
96
@menu
* Introduction::                
97
98
99
100
* Installation::                
* Getting started::             
* Invoking lsh::                
* Invoking lshd::               
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
* Terminology::                 
* Concept Index::               

@detailmenu
 --- The Detailed Node Listing ---

Introduction

* Threats::                     
* Features::                    
* Related techniques::          

Related programs and techniques

* ssh1::                        SSH version 1
* ssh2::                        SSH version 2
* Kerberos::                    Kerberos
* ipsec::                       IP Sec

120
121
122
123
124
125
126
127
128
129
Getting started

* lsh basics::                  Connection with lsh
* tcpip forwarding::            Forwarding @acronym{TCP/IP} ports
* lshd basics::                 Starting the lshd deamon
* public-key::                  Using public-keys
* srp::                         Using SRP authentication
* sexp::                        Examining keys and other S-exp files.

Invoking @command{lsh}
130

131
132
133
134
135
* Algorithms: Algorithm options.  Selecting algorithms.
* Hostauth options::            
* Userauth options::            
* Actions: Action options.      What to do after login.
* Messages: Verbosity options.  Tuning the amount of messages.
136

137
138
139
@end detailmenu
@end menu

140
@node Introduction, Installation, Top, Top
Niels Möller's avatar
Niels Möller committed
141
142
143
144
@comment  node-name,  next,  previous,  up
@chapter Introduction

What is this thing called computer security anyway? Why would you want
145
to use a program like @command{lsh}?
Niels Möller's avatar
Niels Möller committed
146

147
This chapter explains the threats @command{lsh} tries to protect you from,
Niels Möller's avatar
Niels Möller committed
148
and some of the threats that remain. It also describes some of the
149
technologies used in @command{lsh}.
Niels Möller's avatar
Niels Möller committed
150
151
152
153
154
155
156
157
158
159
160
161
162
163

From time to time in this manual, I will speak about the @dfn{enemy}.
This means anybody who is trying to eavesdrop or disturb your private
communication. This usage is technical, and it does not imply that the
enemy is somehow morally inferior to you: The enemy may be some awful
criminals trying to eavesdrop on you, or it may be the police trying to
eavesdrop the same criminals.

The enemy can be a criminal, or a competitor, or your boss who's trying
to find out how much you tell collegues at competing firms. It may be
yours or somebody elses national security officials. Or your
ex-boyfriend who happens to be too curious.

So what can the enemy do to your communications and your privacy?
164
Remember that just because you're paranoid that doesn't mean that nobody
165
is trying to get you@dots{}
Niels Möller's avatar
Niels Möller committed
166
167


168
169
170
171
172
173
174
@menu
* Threats::                     
* Features::                    
* Related techniques::          
@end menu

@node Threats, Features, Introduction, Introduction
Niels Möller's avatar
Niels Möller committed
175
176
177
@comment  node-name,  next,  previous,  up
@section Threats

178
179
When logging in to some other machine via the Internet, either in the
same building or a few continents away, there are several things that
Niels Möller's avatar
Niels Möller committed
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
may be under enemy attack.

@table @asis
@item @dfn{Local attacks}
The enemy controls your local environment. He or her may be looking over
your shoulder. Your local machine might be cracked. Or there may be some
device planted inside your keyboard transmitting everything you type to
the attacker. About the same problems occur if the attacker has taken
control over your target machine, i.e. the remote machine you have
logged in to.

@item @dfn{Denial of service}
The enemy has cut your network cable, effectively stopping your
communication. Even without doing physical damage, the enemy may be able
to flood and overload computers or network equipment. Or disrupt network
195
traffic by sending fake packets to hangup your @acronym{TCP/IP}
Niels Möller's avatar
Niels Möller committed
196
197
198
199
connections.

@item @dfn{Passive eavesdropping}
The enemy may be able to listen to your communication somewhere along
200
its path. With the global Internet, it's difficult to predict who might
Niels Möller's avatar
Niels Möller committed
201
202
203
204
205
206
207
208
209
be able to listen. Internet traffic between buildings just a few hundred
meters apart have been observed temporarily being routed through half a
dozen countries, perhaps a few thousand kilometers.

And even without routing anomalies, it is possible that the enemy has
been able to take control of some nearby machine, and can listen in from
there. Of course, passive eavesdropping is most dangerous if you
transmit cleartext passwords. This is the main reason not to use vanilla
telnet to login to remote systems. Use a telnet with support for
210
211
@acronym{SSL} or Kerberos, or use a program like @command{lsh} or
@command{ssh}. 
Niels Möller's avatar
Niels Möller committed
212
213
214
215
216
217
218
219
220
221
222
223
224

A passive eavesdropper is assumed not to do anything nasty with your
packets beyond listening to them.

@item Name resolution attacks
The translation from symbolic @acronym{DNS} names to numeric
ip-addresses may be controlled by the attacker. In this case, you may
think that you are connecting to a friendly machine, when in fact you
are connecting somewhere else.

@item Fake packets
It is fairly easy to fake the source address of an @acronym{IP}-packet,
although it is more difficult to get hold on the replies to the faked
225
packets. But even without any replies, this can cause serious
Niels Möller's avatar
Niels Möller committed
226
227
228
229
230
231
232
233
234
235
236
237
238
239
problems. 

@item @dfn{Man-in-the-middle} attack
In this attack, the enemy sits between you and the target. When
communicating with you, he pretends to be the target. When communicating
with the target, he pretends to be you. He also passes all information
on more or less unmodified, so that he is invisible to you and the
target. To mount this attack, the enemy either needs physical access to
some network equipment on the path between you and the target, or he has
been able to fool you to connect to him rather than to the target, for
example by manipulating the @acronym{DNS}-system.

@end table

240
@command{lsh} makes no attempt to protect you from local attacks. You have
Niels Möller's avatar
Niels Möller committed
241
242
243
to trust the endpoint machines. It seems really difficult to uphold any
security if the local machine is compromised. This is important to keep
in mind in the ``visitor''-scenario, where you visit a friend or perhaps an
244
Internet café and want to connect to some of the machines at home or at
Niels Möller's avatar
Niels Möller committed
245
246
247
248
249
250
251
work. If the enemy has been able to compromize your friend's or the
café's equipment, you may well be in trouble.

Protection from denial of service attacks is also a very difficult
problem, and @dfn{lsh} makes no attempt to protect you from that.

Instead, the aim of @dfn{lsh}, and most serious tools for cryptographic
252
protection of communications across the net, is to isolate the
Niels Möller's avatar
Niels Möller committed
253
vulnerabilities to the communication endpoints. If you know that the
254
endpoints are safe, the enemy should not be able to compromize your
Niels Möller's avatar
Niels Möller committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
privacy or communications. Except for denial of service attacks (which
at least can't be performed without you noticing it).

First of all, @dfn{lsh} provides protection against passive
eavesdropping. In addition, if you take the appropriate steps to make
sure that hostkeys are properly authenticated, @dfn{lsh} also protects
against man-in-the-middle attacks and in particular against attacks on
the name resolution. In short, you need only trust the security at the
end points: Even if the enemy controls all other network equipment, name
resolution and routing infrastructure, etc, he can't do anything beyond
the denial of service attack.

And at last, remember that there is no such thing as absolute security.
You have to estimate the value of that which you are protecting, and
adjust the security measures so that your enemies will not find it worth
the effort to break them.


273
@node Features, Related techniques, Threats, Introduction
Niels Möller's avatar
Niels Möller committed
274
275
276
@comment  node-name,  next,  previous,  up
@section Other convenient features

277
278
279
@command{lsh} does not only provide more secure replacements for
@command{telnet}, @command{rsh} and @command{rlogin}, it also provides some other
features to make it convenient to communicate securely. But @command{lsh} is
280
still in an early stage of development, so this section is expected to
281
grow with time. One goal for @command{lsh} is to make it reasonable easy to
282
extend it, without messing with the core security functionality.
Niels Möller's avatar
Niels Möller committed
283

284
@command{lsh} can be configured to allow login based on a personal key-pair
Niels Möller's avatar
Niels Möller committed
285
consisting of a private and a public key, so that you can execute remote
286
287
288
commands without typing your password every time. You can also use
Thomas Wu's Secure Remote Password Protocol (SRP). Kerberos support is
on the wish list but not yet supported (@pxref{Kerberos}).
Niels Möller's avatar
Niels Möller committed
289

290
The public-key authentication methods should also be extended to support
Niels Möller's avatar
Niels Möller committed
291
292
293
Simple Public Key Infrastructure (SPKI) certificates, including some
mechanism to delegate restricted logins.

294
295
296
Forwarding of arbitrary @acronym{TCP/IP} connections is provided. This
is useful for tunneling otherwise insecure protocols, like telnet and
pop, through an encrypted @command{lsh} connection.
Niels Möller's avatar
Niels Möller committed
297
298

Convenient tunneling of X is one of the most impressive features of the
299
original @command{ssh} programs. @command{lsh} doesn't do this yet. Other kind
Niels Möller's avatar
Niels Möller committed
300
of tunneling that may turn out to be useful include authentication (i.e.
301
@command{ssh-agent}), general forwarding of @acronym{UDP}, and why not also
Niels Möller's avatar
Niels Möller committed
302
303
304
general ip-tunneling.


305
@node Related techniques,  , Features, Introduction
Niels Möller's avatar
Niels Möller committed
306
307
308
309
@comment  node-name,  next,  previous,  up
@section Related programs and techniques

This sections describes some other programs and techniques related to
310
311
@command{lsh}. The ssh family of programs use mostly the same kind of
security as @command{lsh}. Kerberos and @acronym{IPSEC} operate quite
Niels Möller's avatar
Niels Möller committed
312
313
314
differently, in particular when it comes to protection against
Man-in-the-middle attacks.

315
316
317
318
319
320
321
322
@menu
* ssh1::                        SSH version 1
* ssh2::                        SSH version 2
* Kerberos::                    Kerberos
* ipsec::                       IP Sec
@end menu

@node ssh1, ssh2, Related techniques, Related techniques
Niels Möller's avatar
Niels Möller committed
323
324
325
@comment  node-name,  next,  previous,  up
@subsection ssh-1.x

326
The first of the Secure shell programs was Tatu Ylonen's @command{ssh}. The
Niels Möller's avatar
Niels Möller committed
327
latest of the version 1 series is @code{ssh-1.27} which speaks version
328
329
1.5 of the protocol. The ``free'' version of @code{ssh-1.27} does not allow
commercial use without additional licensing, which makes @code{ssh-1.27}
Niels Möller's avatar
Niels Möller committed
330
non-free software according to the Debian's Free Software Guidelines and
331
the Open Source Definition. 
Niels Möller's avatar
Niels Möller committed
332
333
334
335
336
337

The version 1 protocol has some minor weaknesses, in particular, all
support for using stream ciphers was disabled by default a few versions
back, for security reasons.

There also exists free implementations of ssh-1, for both Unix and
338
339
Windows. @command{ossh} and later OpenSSH are derived from earlier version
av Tatu Ylonen's @command{ssh}, and are free software.
Niels Möller's avatar
Niels Möller committed
340

341
Until @command{lsh} becomes stable and well tested, I would recommend using
Niels Möller's avatar
Niels Möller committed
342
343
some implementation of the ssh-1 protocol.

344
@node ssh2, Kerberos, ssh1, Related techniques
Niels Möller's avatar
Niels Möller committed
345
346
347
@comment  node-name,  next,  previous,  up
@subsection ssh-2.x

348
@command{ssh2} implements the next generation of the Secure Shell
Niels Möller's avatar
Niels Möller committed
349
350
protocol, the development of which is supervised by the @acronym{IETF}
secsh Working Group, although that working groups doesn't seem to be
351
352
very active now. @command{lsh} implements the required subset of this
protocol. It is intended to be compatible with the @command{ssh2} series
Niels Möller's avatar
Niels Möller committed
353
354
of programs distributed by Datafellows.

355
However, the existing versions of @command{ssh2} gets some details of the
Niels Möller's avatar
Niels Möller committed
356
357
358
359
360
361
362
protocol wrong (probably because it predates the protocol
specification), so there is some amount of bug-compatibility required.

Interoperability between independenly developed implementations is one
necessary condition for the ssh-2 protocol to become a Proposed
Standard.

363
364
The license for Datafellow's @command{ssh2} programs is similar to that
for recent versions of @command{ssh1}, but with a narrower definition of
Niels Möller's avatar
Niels Möller committed
365
366
``non-commercial use''.

367
368
369
370
371
Besides @command{lsh} there are few free implementations of the
ssh-2 protocols, but since May 2000 it is supported also by
OpenSSH.


372
@node Kerberos, ipsec, ssh2, Related techniques
Niels Möller's avatar
Niels Möller committed
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
@comment  node-name,  next,  previous,  up
@subsection Kerberos

Kerberos is a key distribution system originally developed in the late
1980:s as a part of Project Athena at @acronym{MIT}. Recent development
have been done at The Royal Institute of Technology, Stockholm
(@acronym{KTH}).

Kerberos uses a central trusted ticket-granting server, and requires
less trust on the local machines in the system. It does not use
public-key technology.

Usually, Kerberos support is compiled into applications such as telnet,
ftp and X-clients. The ssh family of programs, on the other hand, tries
to do all needed magic, for instance to forward X securely, and then
388
provides general @acronym{TCP/IP} forwarding as a kitchen sink.
Niels Möller's avatar
Niels Möller committed
389

390
391
I believe Kerberos' and lsh's protection against passive eavesdropping
are mostly equivalent. The difference is in the set of machines and
392
393
assumptions you have to trust in order to be safe from a
man-in-the-middle attack.
Niels Möller's avatar
Niels Möller committed
394

395
I think the main advantage of @command{lsh} over Kerberos is that it is
Niels Möller's avatar
Niels Möller committed
396
397
398
easier to install and use for on ordinary mortal user. In order to set
up key exchange between two different Kerberos systems (or @dfn{Kerberos
realms}), the respective system operators need to exchange keys. In the
399
case of two random users at two random sites, setting up @command{lsh} or
400
some other program in the ssh family is likely easier than to get the
401
402
operators to spend time and attention. So @command{lsh} should be easier to
use in an anarchistic grass-roots environment.
Niels Möller's avatar
Niels Möller committed
403

404
Another perspective is to combine ssh-features like X and @acronym{TCP/IP}
Niels Möller's avatar
Niels Möller committed
405
406
407
408
forwarding with authentication based on Kerberos. Such an arrangement
may provide the best of two worlds for those who happen to have an
account at a suitable ticket-granting server.

409
@node ipsec,  , Kerberos, Related techniques
Niels Möller's avatar
Niels Möller committed
410
411
412
413
@comment  node-name,  next,  previous,  up
@subsection @acronym{IPSEC}

@acronym{IPSEC} is a set of protocols for protecting general ip-traffic.
414
It is developed by another @acronym{IETF} working group, and is also a
Niels Möller's avatar
Niels Möller committed
415
416
required part of IP version 6.

417
Again, the main difference between @acronym{IPSEC} and Kerberos and ssh
Niels Möller's avatar
Niels Möller committed
418
is the set of machines that have to be secure and the keys that have to
419
be exchanged in order to avoid man-in-the-middle attacks.
Niels Möller's avatar
Niels Möller committed
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438

Current protocols and implementations of @acronym{IPSEC} only provide
authentication of machines; there's nothing analogous to the user
authentication in ssh or Kerberos.

On the other hand, @acronym{IPSEC} provides one distinct advantage over
application level encryption. Because @acronym{IP} and @acronym{TCP}
headers are authenticated, it provides protection against some
denial-of-service attacks. In particular, it makes attacks that cause
hangup of a @acronym{TCP} connection considerably more difficult.

So it makes sense to use both @acronym{IPSEC} and some application
level cryptographic protocol.

Also note that it is possible to use the @dfn{Point-to-Point} PPP
protocol to tunnel arbitrary ip traffic accross an ssh connection. This
arrangement provides some of the functionality of @acronym{IPSEC}, and
is some times referred to as ``a poor man's Virtual Private Network''.

439
440
441
442
@node Installation, Getting started, Introduction, Top
@comment  node-name,  next,  previous,  up
@chapter Installation

443
You install @command{lsh} with the usual @samp{./configure && make &&
444
make install}. For a full listing of the options you can give to
445
@command{configure}, use @samp{./configure --help}. For example, use
446
447
448
449
@option{--without-pty} to disable pty-support.

The most commonly used option is @option{--prefix}, which tells
configure where lsh should be installed. Default prefix is
450
@file{/usr/local}. The @command{lshd} server is installed in
451
452
453
@file{$prefix/sbin}, all other programs and scripts are installed in
@file{$prefix/bin}. 

454
455
456
457
The configure script tries to figure out of the linker needs any special
flags specifying where to find dynamically linked libraries at run time
(one case where this matters is if you have a dynamic libz.so installed
in a non -standard place). Usually, you can use
458

459
460
461
462
463
464
@samp{./configure --with-lib-path=/opt/lib:/other/place}

to specify extra library directories, and the configure script should do
the right thing. If it doesn't work, or you believe that you know your
system better than @command{configure}, just set LDFLAGS and/or
LD_LIBRARY_PATH to the right values instead.
465
466
467
468


@node Getting started, Invoking lsh, Installation, Top
@comment  node-name,  next,  previous,  up
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
@chapter Getting started
This section tells you how to perform some common tasks using the
@command{lsh} suit of programs, without covering all options and
possibilities.

@menu
* lsh basics::                  Connection with lsh
* tcpip forwarding::            Forwarding @acronym{TCP/IP} ports
* lshd basics::                 Starting the lshd deamon
* public-key::                  Using public-keys
* srp::                         Using SRP authentication
* sexp::                        Examining keys and other S-exp files.
@end menu

@node lsh basics, tcpip forwarding, Getting started, Getting started
@comment  node-name,  next,  previous,  up
@section @command{lsh} basics

@command{lsh} is the program you use for connection to a remote machine. A
few examples are:

@samp{lsh sara.lysator.liu.se}

Connects to @samp{sara.lysator.liu.se} and starts an interactive shell.
In this example, and in the rest of the examples in this section, lsh
will ask for your password, unless you have public-key user
authentication set up.

The first time you try to connect between two machines, @command{lsh}
typically complains about about an ``unknown host key''. This is because
it has no reason to believe that it was the right machine that answered,
and not a machine controlled by the enemy (@pxref{Threats}). The default
behaviour is to never ever accept a server that is not properly
authenticated. And a machine is considered authentic if it follows the
protocol and has its public hostkey listed in @file{~/.lsh/known_hosts}.

To make lsh less paranoid, use

@samp{lsh --sloppy-host-authentication sara.lysator.liu.se}

Then @command{lsh} will display a @dfn{fingerprint} of the host key of the
remote machine, and ask you if it is correct. If so, the machine is
considered authentic and its key is appended to the file
@file{~/.lsh/captured_keys}. You can copy keys you have verified to
@file{~/.lsh/known_hosts}.

You can even use

@samp{lsh --sloppy-host-authentication --capture-to ~/.lsh/known_hosts}

to get @command{lsh} to behave more like the traditional @command{ssh} program.

You can create fingerprints for the hostkeys you need regularly, and
keep with you (@pxref{sexp}).

@samp{lsh -l omar sara.lysator.liu.se}

Connects, like above, but tries to log in as the user ``omar''.

@samp{lsh sara.lysator.liu.se tar cf - some/dir | (cd /target/dir && tar -xf -)}

Copies a directory from the remote machine, by executing one remote and
one local @command{tar} process and piping them together.

@samp{CVS_RSH=lsh cvs -d sara.lysator.liu.se:/lysator/cvsroot co lsh}

Checks out the @command{lsh} source code from cvs.


@node  tcpip forwarding, lshd basics, lsh basics, Getting started
@comment  node-name,  next,  previous,  up
@section Port forwarding

One useful feature of @command{lsh} and other ssh-like programs is the
ability to forward arbitrary connections inside the encrypted
connection. There are two flavors: ``local'' and ``remote'' forwarding.

An example of local forwarding is

@samp{lsh -L 4000:kom.lysator.liu.se:4894 sara.lysator.liu.se}

This makes @command{lsh} listen on port 4000 on the @emph{local} machine. When
someone connects, @command{lsh} asks the server to open a connection from
the @emph{remote} machine (i.e. @samp{sara}) to port 4894 on another machine
(i.e. @samp{kom}). The two connections are piped together using an
encrypted channel.

There are a few things that should be noted here:

@itemize @bullet
@item
By default, @command{lsh} only listens on the loopback interface, so only
clients on the same machine can use the tunnel. To listen on all
interfaces, use the @option{-g} flag.

@item
A connection through the tunnel consists of three parts:

@enumerate
@item
From a client socket to the local port (4000 in this example) that
@command{lsh} listens on.

@item
The tunnel itself, from the local machine to the tunnel endpoint,
which is @samp{sara} in this example.

@item
The connection from the tunnel endpoint to the ultimate target, in this
example from @samp{sara} to @samp{kom}.

@end enumerate
581

582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
Only the middle part is protected by @command{lsh}, the first and the last
part are sent @emph{in the clear}. So forwarding doesn't offer much
protection unless the tunnel endpoint and the ultimate target machine
are close to eachother. They should usually be either the same machine,
or two machines connected by a local network that is trusted.

@item
Port forwarding is very useful for traversing firewalls. Of course, you
don't need to use lsh-style forwarding just to get out, there are other
tools like HTTPTunnel for that. But @command{lsh} helps you get out through
the firewall in a secure way.

@item
Prt forwarding is done in addition to anything else @command{lsh} is doing.
In the example above, a tunnel is set up, but @command{lsh} will also start
an interactive shell for you. Just like the @option{-L} was not present.
If this is not what you want, the @option{-N} is for you
(@pxref{Invoking lsh})
@end itemize

Remote forwarding is similar, but asks the @emph{remote} machine to
listen on a port. An example of remote forwarding is

@samp{lsh -g -R 8080:localhost:80 sara.lysator.liu.se}

This ask the remote machine to listen on port 8080 (note that you are
probably not authorized to listen on port 80). Whenever someone
connects, the connection is tunnelled to your local machine, and
directed to port 80 on the same machine. Note the use of @option{-g};
the effect is to allow anybody in the world to use the tunnel to connect
to your local webserver.

The same considerations that apply to forwarded local ports apply also to
forwarded remote ports.

At last, you can use any number of @option{-L} and @option{-R} options
on the same command line.


@node lshd basics, public-key, tcpip forwarding, Getting started
@comment  node-name,  next,  previous,  up
@section lshd basics
There are no global configuration files for @command{lshd}; all
625
626
configuration is done with command line switches @xref{Invoking lshd}.

627
To run @command{lshd}, you must first create a hostkey, usually stored in
628
629
@file{/etc/lsh_host_key}. To do this, run

630
@samp{lsh_keygen | lsh_writekey -o /etc/lsh_host_key}
631
632

This will also create a file @file{/etc/lsh_host_key.pub},
633
containing the corresponding public key. 
634
635
636
637
638

A typical command line for starting lshd in daemon mode is simply

@samp{lshd --daemonic}

639
640
641
642
You can find init script for @command{lshd} tailored for Debian's and
RedHat's GNU/Linux systems in the @file{contrib} directory. 

It is also possible to let @command{init} start @command{lshd}, by adding it in
643
644
@file{/etc/inittab}.

645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802

@node public-key, srp, lshd basics, Getting started
@comment  node-name,  next,  previous,  up
@section Using public-key user authentication

Public-key user authentication is a way to authenticate for login,
without having to type any passwords. There are two steps: Creating a
key pair, and authorizing the public key to the systems where you want
to log in.

To create a keypair, run

@samp{lsh_keygen | lsh_writekey}

This can take some time, but in the end it creates two files
@file{~/.lsh/identity} and @file{~/.lsh/identity.pub}.

If you want to use the key to login to some other machine, say
@samp{sara}, you can do that by first copying the key,

@samp{lsh sara.lysator.liu.se '>my-key.pub' <~/.lsh/identity.pub}

then authorizing it by executing, on @samp{sara},

@samp{lsh-authorize my-key.pub}

For security reasons, you should keep the private key
@file{~/.lsh/identity} secret. Anybody who can read that file will be
able to login in your name to any machine where the corresponding public
key is registered as an authorized key.

Naturally, you should also make sure not to authorize any keyys but your
own. For instance, it is inappropriate to use an insecure mechanism such
as unauthenticated email, @code{ftp} or @code{http} to transfer your
public key to the machines where you want to authorize it.

If you have accounts on several systems, you usually create a single
keypair on each of the systems, and on each system you authorize some or
all of your public keys for login.

Note that @command{lsh} does currently @emph{not} encrypt your private
key in any way. That means that you can lose it if a backup tape gets
int the wrong hands, and if you use NFS it will likely be sent in the
clear across the local network. (Actually, you can decrypt the key using
a pass phrase, by passing the @option{-c 3des} to
@command{lsh_writekey}, but @command{lsh} doesn't yet support decrypting
it).


@node srp, sexp, public-key, Getting started
@comment  node-name,  next,  previous,  up
@section Using Secure Remote Password authentication

The Secure Remote Password protocol is a fairly new protocol that
provides mutual authentication based on a password. To use it, you must
first choose a secret password. Next, you create a @dfn{password
verifier} that is derived from the password. The verifier is stored on
the target machine (i.e. the machine you want to log in to).

To create a verifier, you run the @command{srp-gen} program and type
your new password. You have to do it on either the target machine,
redirecting the output to ~/.lsh/srp-verifier, or you can generate it on
some other machine and copy it to the target.

The main advantage of using @acronym{SRP} is that you use the password
not only to get access to the remote machine, but you also use it to
authenticate the remote machine. I.e. you can use it to connect
securely, @emph{without} having to know any hostkeys or fingerprints
before you connect!

For instance, you could connect using @acronym{SRP} to fetch the hostkey
fingerprint for the remote machine, as a kind of bootstrapping
procedure, and then use traditional authentication methods for further
connections.

For this to work, the verifier @emph{must} be kept @emph{secret}. If the
enemy gets your verifier, he can mount some attacks:

@itemize @bullet
@item
He can mount a @dfn{dictionary attack} on your password, i.e. generate a large
list of likely password and check if any of them matches yours.

@item
He can impersonate the server. That means that if you try to connect to
the remote machine using @acronym{SRP}, and the attacker can intercept
your connection (e.g. by attacking the name resolution or routing
system) he can successfully pretend to be the real server.
@end itemize

If you use @acronym{SRP} to get the hostkey or fingerprint for the
remote machine, as outlined above, the impersonation attack destroys
security, you could just as well connect the hostkey presented by the
remote server without verifying it at all.

If you use @acronym{SRP} exclusively, the situation seems somewhat
different. As far as I can see, an attacker knowing your verifier can
not mount a traditional man-in-the-middle-attack: He can play the
server's part when talking to you, but in order to play your part when
talking to the real server, he needs to know your password as well.

@acronym{SRP} support is disabled by default, but can be enabled by the
@option{--srp-keyexchange} option to @command{lshd} and @command{lsh}
(naturally, it won't be used unless enabled on both sides). At the time
of this writing, SRP is too new to be trusted, at least according to
conservative cryptographers (and remember that conservatism is a virtue
when it comes to security).

And even if @acronym{SRP} in itself is secure, the way @command{lsh}
integrates it into the @code{ssh} protocol has not had much review.

The bottom line of this disclaimer is that the @acronym{SRP} support in
@command{lsh} should be considered experimental.

As far as I know, @acronym{SRP} is not supported by any other @code{ssh}
implementation. The protocol @command{lsh} uses is described in the
@file{doc/srp-spec.txt}.

@node sexp,  , srp, Getting started
@comment  node-name,  next,  previous,  up
@section Examining keys and other S-exp files

Keys and most other objects @command{lsh} needs to store on disk are
represented as so called S-expressions or ``sexps'' for short.
S-expressions have their roots in the Lisp world, and a variant of them
is the format used by the Simple Public Key Infrastructure
(@acronym{SPKI}). Currently, @command{lsh}'s support for @acronym{SPKI}
is quite limited, but it uses @acronym{SPKI}'s formats for keys and
Access Control Lists (@acronym{ACL}'s).

There are several flavours of the sexp syntax:

@itemize @bullet
@item
The canonical syntax is somewhere between a text and a binary format,
and is extremely easy for programs to read and write.

@item
The transport syntax, which is suitable when embedding sexps in text
files. It is essentially the canonical representation, encoded using
base64.

@item
The advanced syntax, which is intended for humans to read and write, and
bears some resemblance to List expressions.
@end itemize

To see what your @file{~/.lsh/known_hosts} file really contains, try

@samp{sexp-conv -i advanced < ~/.lsh/known_hosts}

The @command{sexp-conv} program can also be used to computes
fingerprints. The fingerprint of a key (or any sexp, for that matter) is
simply the hash of its canonical representation. For example,

@samp{sexp-conv --raw-hash </etc/lsh_host_key.pub}


803
804
@node Invoking lsh, Invoking lshd, Getting started, Top
@comment  node-name,  next,  previous,  up
805
@chapter Invoking @command{lsh}
806

807
You use @command{lsh} to login to a remote machine. Basic usage is
808
809
810
811

@samp{lsh [-p @var{port number}] sara.lysator.liu.se}

which attempts to connect, login, and start an interactive shell on the
812
remote machine. Default @var{port number} is whatever your system's
813
@file{/etc/services} lists for @command{ssh}. Usually, that is port 22.
814

815
There is a plethora of options to @command{lsh}, to let you configure where
816
and how to connect, how to authenticate, and what you want to do once
817
818
819
properly logged in to the remote host. Many options have both long and
short forms. This manual does not list all variants; for a full listing
of supported options, use @samp{lsh --help}.
820
821

@menu
822
823
824
825
826
* Algorithms: Algorithm options.  Selecting algorithms.
* Hostauth options::            
* Userauth options::            
* Actions: Action options.      What to do after login.
* Messages: Verbosity options.  Tuning the amount of messages.
827
828
829
830
831
832
@end menu

@node Algorithm options, Hostauth options, Invoking lsh, Invoking lsh
@comment  node-name,  next,  previous,  up
@section Algorithm options

833
Before a packet is sent, each packet can be compressed, encrypted
834
835
836
837
838
839
840
841
and authenticated, in that order. When the packet is received, it is
first decrypted, next it is checked that it is authenticated properly,
and finally it is decompressed. The algorithms used for this are
negotiated with the peer at the other end of the connection, as a part
of the initial handshake and key exchange.

Each party provides a list of supported algorithms, and the first
algorithm listed by the client, which is also found on the server's
842
843
844
845
846
847
848
849
850
851
852
list, is selected. Note that this implies that order in which algorithms
are listed on the server's list doesn't matter: if several algorithms
are present on both the server's and the client's lists, it's the
client's order that determines which algorithm is selected.

Algorithms of different types, e.g. data compression and message
authentication, are negotiated independently. Furthermore, algorithms
used for transmission from the client to the server are independent of
the algorithms used for transmission from the server to the client.
There are therefore no less than six different lists that could be
configured at each end.
853
854
855
856
857

The command line options for lsh and lshd don't let you specify
arbitrary lists. For instance, you can't specify different preferences
for sending and receiving.

858
There is a set of default algorithm preferences. When you use a command
859
860
861
862
863
864
line option to say that you want to use @var{algorithm} for one of the
algorithms, the default list is replaced with a list containing the
single element @var{algorithm}. For example, if you use @option{-c
arcfour} to say that you want to use @code{arcfour} as the encryption
algorithm, the connection will either end up using @code{arcfour}, or
algorithm negotiation will fail because the peer doesn't support
865
@code{arcfour}.
866

867
@multitable @columnfractions 0.1 0.2 0.2 0.5
868
869
870
871
@item Option
  @tab Algorithm type @tab Default @tab
@item @option{-z} @tab Data compression
  @tab @code{none}, @code{zlib}
872

873
874
  @tab The default preference list supports zlib compression, but
prefers not to use it. 
875

876
877
@item @option{-c} @tab Encryption
  @tab @code{3dec-cbc}, @code{blowfish-cbc}, @code{cast128-cbc},
878
879
@code{twofish-cbc}, @code{arcfour}

880
  @tab The default encryption algorithm is tripple-DES in CBC mode. This
881
882
seems to be the algorithm of choice among conservative cryptographers.

883
884
@item @option{-m} @tab Message Authentication
  @tab @code{hmac-sha1}, @code{hmac-md5}
885

886
  @tab Both supported message authentication algorithms are of the
887
@acronym{HMAC} family.
888
889
@end multitable

890
891
892
893
894
895
896
As a special case, @option{-z} with no argument changes the compression
algorithm list to @code{zlib}, @code{none}, which means that you want to
use @code{zlib} if the other end supports it. This is different from @option{-z
zlib} which causes the negotiation to fail if the other end doesn't
support @code{zlib}.


897
898
899
900
@node Hostauth options, Userauth options, Algorithm options, Invoking lsh
@comment  node-name,  next,  previous,  up
@section Host authentication options

Niels Möller's avatar
Niels Möller committed
901
902
As described earlier @pxref{Threats}, proper authentication of the
remote host is crucial to protect the connection against
903
Man-in-the-middle attacks. By default, @command{lsh} verifies the server's
904
claimed host key against the @dfn{Access Control Lists} in
Niels Möller's avatar
Niels Möller committed
905
906
907
908
909
910
911
912
913
914
@file{~/.lsh/known_hosts}. If the remote host cannot be authenticated,
the connection is dropped.

The options that change this behaviour are

@table @option
@item --host-db
Specifies the location of the @acronym{ACL} file.

@item --sloppy-host-authentication
915
Tell @command{lsh} not to drop the connection if the server's key can not
916
917
918
be authenticated. Instead, it display the fingerprint of the key, and
ask if it is trusted. The received key is also appended to the file
@file{~/.lsh/captured_keys}. If run in quiet mode, @samp{lsh -q
919
--sloppy-host-authentication}, @command{lsh} connects to any host, no
920
921
questions asked.

Niels Möller's avatar
Niels Möller committed
922
@item --strict-host-authentication
923
924
Disable sloppy operation (this is the default behaviour).

Niels Möller's avatar
Niels Möller committed
925
@item --capture-to
926
927
Use some other file than @file{~/.lsh/captured_keys}. For example,
@samp{--sloppy-host-authentication --capture-to ~/.lsh/known_hosts}
928
makes @command{lsh} behave more like the @command{ssh} program.
Niels Möller's avatar
Niels Möller committed
929
930
931

@end table

932
933
934
935
@node Userauth options, Action options, Hostauth options, Invoking lsh
@comment  node-name,  next,  previous,  up
@section User authentication options

936
937
938
939
940
941
942
@table @option

@item -l
Provide a name to use when logging in. By default, the value of the
@env{LOGNAME} variable is used.

@item -i
943
Try the keys from this file to log in. By default, @command{lsh} uses
944
945
946
947
948
949
950
951
952
@file{~/.lsh/identity}, if it exists. It ought to be possible to use
several @option{-i} options to use more than one file, but that is
currently not implemented.

@item --no-publickey
Don't attempt to log in using public key authentication.

@end table

953
954
955
956
@node Action options, Verbosity options, Userauth options, Invoking lsh
@comment  node-name,  next,  previous,  up
@section Action options

957
There are many things @command{lsh} can do once you are logged in. There
958
959
960
961
962
963
964
are two types of options that control this: @dfn{actions} and
@dfn{action modifiers}. For short options, actions use uppercase letters
and modifiers use lowercase.

For each modifier @option{--foo} there's also a negated form
@option{--no-foo}. Options can also be negated be preceding it with the
special option @option{-n}. This is mainly useful for negating short
965
options. For instance, use @option{-nt} to tell @command{lsh} not to
966
967
968
969
970
971
972
973
974
975
976
977
request a remote pseudo terminal. Each modifier and its negation can be
used several times on the command line. For each action, the latest
previous modifier of each pair apply.

First, the actions:

@table @option

@item -L
Requests forwarding of a local port. This option takes mandatory
argument of the form
@var{listen-port}:@var{target-host}:@var{target-port}. This option tells
978
979
@command{lsh} to listen on @var{listen-port} on the local machine. When
someone conects to that port, @command{lsh} asks the remote server to open
980
981
a connection to @var{target-port} on @var{target-host}, and if it
succeeds, the two connections are joined together through an the
982
@command{lsh} connection. Both port numbers should be given in decimal.
983
984
985

@item -R
Requests forwarding of a remote port. It takes one mandatory argument,
986
just like @option{-L}. But in this case @command{lsh} asks the
987
988
@emph{remote} server to listen on @var{listen-port}. When someone
connects to the remote hosts, the server will inform the local
989
@command{lsh}. The local @command{lsh} then connects to @var{target-port} on
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
@var{target-host}.

@item -E
This option is not yet implemented. It takes one mandatory argument,
which is a command to be executed on the remote machine.

@item -S
Start a shell on the remote machine. Currently not implemented, except
as the default action.

@item -N
This is a no-operation action. It inhibits the default action, which is
to start an interactive shell on the remote machine. It is useful if you
want to set up a few forwarded tunnels, and nothing more.

@end table

If there are trailing arguments after the name of the remote system,
this is equivalent to a @option{-E} option, with a command string
constructed by taking all the remaining arguments, separated by spaces.
This implies that the arguments are usually expanded first by the local
shell, and then the resulting command string is interpreted again by the
remote system. In any case, just like @option{-E}, this is not yet
implemented.

If there are no trailing arguments after the name of the remote system,
and the @option{-N} option is not given, the default action is to start
a shell on the remote machine. I.e. this is equivalent to the
@option{-S} option.

There are a few supported modifiers:

@table @option

@item -t
1025
Request a pseudo terminal. @command{lsh} asks the remote system to allocate
1026
1027
a pseudo terminal. If it succeeds, the local terminal is set to raw
mode. The default behaviour is to request a pty if and only if the
1028
local @command{lsh} process has a controlling terminal. This modifier
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
applies to actions that create remote processes, i.e. @option{-E} and
@option{-S}, as well as the default actions.

Currently, this option is ignored if there is no local terminal.

@item -g
Gateway mode. This option applies to the forwarding actions, i.e.
@option{-L} and @option{-R}. By default, only connections to the
loopback interface, ip 127.0.0.1, are forwared. This implies that only
processes on the same machine can use the forwarded tunnel directly. If
the -g modifier is in effect, the forwarding party will listen on
@emph{all} network interfaces.

@end table

1044
1045
1046
1047
@node Verbosity options,  , Action options, Invoking lsh
@comment  node-name,  next,  previous,  up
@section Verbosity options

1048
These options determines what messages @command{lsh} writes on
1049
1050
1051
1052
1053
1054
1055
1056
1057
its stderr.

@table @option

@item -q
Quiet mode. Disables all messages and all questions. Except password
prompts and fatal internal errors.

@item -v
1058
Verbose mode. Makes @command{lsh} a little more verbose. The intention is
1059
to provide information that is useful for ordinary trouble shooting,
1060
and makes sense also to those not familiar with @command{lsh} internals.
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073

@item --trace
Trace mode. Prints some internal information to aid tracking
lsh's flow of control.

@item --debug.
Debug mode. Dumps @emph{a lot} of information, including dumps of all
sent and received packets. It tries to avoid dumping highly sensitive data,
such as private keys and the contents of @code{SSH_MSG_USERAUTH_REQUEST}
messages, but you should still use it with care.

@end table

1074
1075
@node Invoking lshd, Terminology, Invoking lsh, Top
@comment  node-name,  next,  previous,  up
1076
@chapter Invoking @command{lshd}
1077

1078
@command{lshd} is a server that accepts connections from clients speaking
1079
1080
1081
1082
1083
the Secure Shell Protocol. It is usually started automatically when the
systems boots, and runs with root privileges. However, it is also
possible to start lshd manually, and with user privileges.

There is currently no configuration files. Instead, command line options
1084
are used to tell @command{lshd} what to do. Many options have @option{--foo}
1085
1086
1087
and @option{--no-foo} variants. Options specifying the default behaviour
are not listed here.

1088
Some of the options are the shared with @command{lsh}. In particular, see
1089
1090
@ref{Algorithm options} and @ref{Verbosity options}.

1091
Options specific to the @command{lshd} server are:
1092
1093
1094
1095
1096
1097
1098
1099

@table @option

@item -p
Port to listen to. The mandatory argument is a decimal port number or a
service name. Default is "ssh", usually port 22.

@item --interface
1100
Network interface to listen on. By default, @command{lshd} listens on all
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
interfaces.

@item -h
Location of the server's private key file. By default,
@file{/etc/lsh_host_key}.

@item -i
Variant of the s-expression syntax to use when reading the host key.
Default is to use transport format. Not a terribly useful option.

@item --ssh1-fallback
1112
This options enables fallback to @command{ssh1}. @command{lshd} doesn't
1113
1114
1115
1116
implement version 1 of the Secure Shell Protocol. But it can fork an ssh1
server when an old client connects. Falling back to ssh1 is inefficient,
and requires some special features of the server fallen back to. It
should work with the sshd daemon supplied with reasonably new versions of
1117
Datafellow's @command{sshd1}, and with @command{openssh}.
1118
1119
1120
1121
1122
1123

The optional argument provides the filename of the ssh1 daemon to use.
Default name is @file{/usr/local/sbin/sshd1}, unless something else was
configured at compile time.

@item --daemonic
1124
Enables daemonic mode. @command{lshd} forks into the background, redirects
1125
1126
1127
its stdio handles to @file{/dev/null}, changes its working directory to
@file{/}, and redirects any diagnostic or debugging messages via syslog.

1128
1129
@command{lshd} should be able to deal with the environment it inherits if it
is started by @command{init} or @command{inetd}, but this is not really tested.
1130
1131
1132

@item --pid-file
Creates a locked pid file, to make it easier to write start and stop
1133
scripts for @command{lshd}. The mandatory argument provides the filename.
1134
1135
1136
1137
This option is enabled by default when operating in daemonic mode, and
the default filename is @file{/var/run/lshd.pid}.

@item --enable-core
1138
1139
By default, @command{lshd} disables core dumps, to avoid leaking sensitive
information. This option changes that behaviour, and allows @command{lshd}
1140
1141
1142
1143
1144
1145
1146
1147
to dump core on fatal errors.

@item --no-password
Disable the "password" user authentication mechanism. 

@item --no-publickey
Disable the "publickey" user authentication mechanism.

1148
@item --root-login
1149
Enable root login. By default, root can not log in using @command{lshd}.
1150

1151
1152
1153
1154
1155
1156
1157
1158
@item --no-pty-support
Disable support for pseudo terminals.

@item --no-tcp-forward
Disable support for tcp forwarding, in both directions.

@end table

1159
1160

@node Terminology, Concept Index, Invoking lshd, Top
Niels Möller's avatar
Niels Möller committed
1161
@comment  node-name,  next,  previous,  up
1162
@chapter Terminology
Niels Möller's avatar
Niels Möller committed
1163

1164
@node    Concept Index,  , Terminology, Top
Niels Möller's avatar
Niels Möller committed
1165
1166
1167
1168
1169
1170
1171
1172
1173
@comment  node-name,  next,  previous,  up
@unnumbered Concept Index

@printindex cp

@contents

     
@bye