File: UserKeyManager.html

package info (click to toggle)
libnet-ssh-ruby 1%3A1.1.4-1.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,532 kB
  • ctags: 2,464
  • sloc: ruby: 10,876; makefile: 3
file content (566 lines) | stat: -rw-r--r-- 27,056 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
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
47
48
49
50
51
52
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>Class: Net::SSH::UserAuth::UserKeyManager</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />

    <script language="JavaScript" type="text/javascript">
    // <![CDATA[

        function toggleSource( id )
        {
          var elem
          var link

          if( document.getElementById )
          {
            elem = document.getElementById( id )
            link = document.getElementById( "l_" + id )
          }
          else if ( document.all )
          {
            elem = eval( "document.all." + id )
            link = eval( "document.all.l_" + id )
          }
          else
            return false;

          if( elem.style.display == "block" )
          {
            elem.style.display = "none"
            link.innerHTML = "show source"
          }
          else
          {
            elem.style.display = "block"
            link.innerHTML = "hide source"
          }
        }

        function openCode( url )
        {
          window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
        }
      // ]]>
    </script>
  </head>

  <body>
  <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
  <td class="file-title"><span class="file-title-prefix">Class</span><br />Net::SSH::UserAuth::UserKeyManager</td>
  <td align="right">
    <table cellspacing=0 cellpadding=2>
      <tr valign="top">
        <td>In:</td>
        <td>
<a href="../../../../files/lib/net/ssh/userauth/userkeys_rb.html">lib/net/ssh/userauth/userkeys.rb</a>
        </td>
      </tr>
    <tr>
      <td>Parent:</td>
      <td>
Object
     </td>
   </tr>
         </table>
        </td>
        </tr>
      </table>
 <!-- banner header -->

  <div id="bodyContent">
      <div id="content">

  <div class="description"><p>
This class encapsulates all operations done by clients on a user&#8216;s
private keys. In practice, the client should never need a reference to a
private key; instead, they grab a list of &quot;<a
href="UserKeyManager.html#M000155">identities</a>&quot; (public keys) that
are available from the <a href="UserKeyManager.html">UserKeyManager</a>,
and then use the <a href="UserKeyManager.html">UserKeyManager</a> to do
various private key operations using those <a
href="UserKeyManager.html#M000155">identities</a>.
</p>
<p>
The <a href="UserKeyManager.html">UserKeyManager</a> also uses the <a
href="Agent.html">Agent</a> class to encapsulate the ssh-agent. Thus, from
a client&#8216;s perspective it is completely hidden whether an identity
comes from the ssh-agent or from a file on disk.
</p>
</div>



  <div class="sectiontitle">Methods</div>
  <ul>
  <li><a href="#M000152">&lt;&lt;</a></li>
  <li><a href="#M000151">add</a></li>
  <li><a href="#M000153">add_host_key</a></li>
  <li><a href="#M000149">clear!</a></li>
  <li><a href="#M000150">clear_host!</a></li>
  <li><a href="#M000154">finish</a></li>
  <li><a href="#M000156">host_identities</a></li>
  <li><a href="#M000155">identities</a></li>
  <li><a href="#M000148">new</a></li>
  <li><a href="#M000157">sign</a></li>
  <li><a href="#M000159">use_agent=</a></li>
  <li><a href="#M000158">use_agent?</a></li>
  </ul>





  <div class="sectiontitle">Attributes</div>
  <table border='0' cellpadding='5'>
  <tr valign='top'>
    <td class='attr-rw'>
[W]
    </td>
    <td class='attr-name'>agent_factory</td>
    <td class='attr-desc'>
The agent factory to use when a <a
href="UserKeyManager.html#M000148">new</a> agent instance is needed.

</td>
  </tr>
  <tr valign='top'>
    <td class='attr-rw'>
[W]
    </td>
    <td class='attr-name'>buffers</td>
    <td class='attr-desc'>
The buffer manager to use for providing <a
href="UserKeyManager.html#M000148">new</a> buffer instances.

</td>
  </tr>
  <tr valign='top'>
    <td class='attr-rw'>
[R]
    </td>
    <td class='attr-name'>host_key_files</td>
    <td class='attr-desc'>
The list of host key files that will be examined

</td>
  </tr>
  <tr valign='top'>
    <td class='attr-rw'>
[W]
    </td>
    <td class='attr-name'>key_existence_tester</td>
    <td class='attr-desc'>
The object that will be used to test whether a given key file is readable.
This object must only respond to &quot;readable?&quot; with one parameter,
the file to test the readability of.

</td>
  </tr>
  <tr valign='top'>
    <td class='attr-rw'>
[R]
    </td>
    <td class='attr-name'>key_files</td>
    <td class='attr-desc'>
The list of user key files that will be examined

</td>
  </tr>
  <tr valign='top'>
    <td class='attr-rw'>
[W]
    </td>
    <td class='attr-name'>keys</td>
    <td class='attr-desc'>
The key manager instance to use for managing keys

</td>
  </tr>
  <tr valign='top'>
    <td class='attr-rw'>
[W]
    </td>
    <td class='attr-name'>log</td>
    <td class='attr-desc'>
The logger instance to use for logging messages

</td>
  </tr>
  </table>

<div class="sectiontitle">Public Class methods</div>
<div class="method">
  <div class="title">
    <a name="M000148"></a><b>new</b>()
  </div>
  <div class="description">
  <p>
Create a <a href="UserKeyManager.html#M000148">new</a> <a
href="UserKeyManager.html">UserKeyManager</a>. By default, the manager will
use the ssh-agent (if it is running).
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000148_source')" id="l_M000148_source">show source</a> ]</p>
  <div id="M000148_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 64</span>
64:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
65:           <span class="ruby-ivar">@key_files</span> = []
66:           <span class="ruby-ivar">@host_key_files</span> = []
67:           <span class="ruby-ivar">@use_agent</span> = <span class="ruby-keyword kw">true</span>
68:           <span class="ruby-ivar">@agent</span> = <span class="ruby-keyword kw">nil</span>
69:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="sectiontitle">Public Instance methods</div>
<div class="method">
  <div class="title">
    <a name="M000152"></a><b>&lt;&lt;</b>( key_file )
  </div>
  <div class="description">
  <p>
Alias for <a href="UserKeyManager.html#M000151">add</a>
</p>
  </div>
</div>
<div class="method">
  <div class="title">
    <a name="M000151"></a><b>add</b>( key_file )
  </div>
  <div class="description">
  <p>
Add the given key_file to the list of key files that will be used.
</p>
  </div>
<div class="aka">
  This method is also aliased as
  <a href="UserKeyManager.html#M000152"><<</a>
</div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000151_source')" id="l_M000151_source">show source</a> ]</p>
  <div id="M000151_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 92</span>
92:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>( <span class="ruby-identifier">key_file</span> )
93:           <span class="ruby-ivar">@key_files</span>.<span class="ruby-identifier">push</span>( <span class="ruby-identifier">key_file</span> ).<span class="ruby-identifier">uniq!</span>
94:           <span class="ruby-keyword kw">self</span>
95:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000153"></a><b>add_host_key</b>( key_file )
  </div>
  <div class="description">
  <p>
Add the given key_file to the list of host key files that will be used.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000153_source')" id="l_M000153_source">show source</a> ]</p>
  <div id="M000153_source" class="dyn-source">
<pre>
     <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 101</span>
101:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_host_key</span>( <span class="ruby-identifier">key_file</span> )
102:           <span class="ruby-ivar">@host_key_files</span>.<span class="ruby-identifier">push</span>( <span class="ruby-identifier">key_file</span> ).<span class="ruby-identifier">uniq!</span>
103:           <span class="ruby-keyword kw">self</span>
104:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000149"></a><b>clear!</b>()
  </div>
  <div class="description">
  <p>
Clear all knowledge of any loaded user keys. This also clears the list of
default identity files that are to be loaded, thus making it appropriate to
use if a client wishes to NOT use the default identity files.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000149_source')" id="l_M000149_source">show source</a> ]</p>
  <div id="M000149_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 75</span>
75:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear!</span>
76:           <span class="ruby-ivar">@key_files</span> = []
77:           <span class="ruby-ivar">@known_identities</span> = <span class="ruby-keyword kw">nil</span>
78:           <span class="ruby-keyword kw">self</span>
79:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000150"></a><b>clear_host!</b>()
  </div>
  <div class="description">
  <p>
Clear all knowledge of any loaded host keys. This also clears the list of
default identity files that are to be loaded, thus making it appropriate to
use if a client wishes to NOT use the default identity files.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000150_source')" id="l_M000150_source">show source</a> ]</p>
  <div id="M000150_source" class="dyn-source">
<pre>
    <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 85</span>
85:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_host!</span>
86:           <span class="ruby-ivar">@host_key_files</span> = []
87:           <span class="ruby-ivar">@known_host_identities</span> = <span class="ruby-keyword kw">nil</span>
88:           <span class="ruby-keyword kw">self</span>
89:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000154"></a><b>finish</b>()
  </div>
  <div class="description">
  <p>
This is used as a hint to the <a
href="UserKeyManager.html">UserKeyManager</a> indicating that the agent
connection is no longer needed. Any other open resources may be closed at
this time.
</p>
<p>
Calling this does NOT indicate that the <a
href="UserKeyManager.html">UserKeyManager</a> will no longer be used.
Identities may still be requested and operations done on loaded <a
href="UserKeyManager.html#M000155">identities</a>, in which case, the agent
will be automatically reconnected. This method simply allows the client
connection to be closed when it will not be used in the immediate future.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000154_source')" id="l_M000154_source">show source</a> ]</p>
  <div id="M000154_source" class="dyn-source">
<pre>
     <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 115</span>
115:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finish</span>
116:           <span class="ruby-identifier">close_agent</span>
117:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000156"></a><b>host_identities</b>()
  </div>
  <div class="description">
  <p>
Returns an array of host <a
href="UserKeyManager.html#M000155">identities</a> (public keys) known to
this manager. Host <a href="UserKeyManager.html#M000155">identities</a> are
those that identify the current host, and are used (typically) for
hostbased authentication.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000156_source')" id="l_M000156_source">show source</a> ]</p>
  <div id="M000156_source" class="dyn-source">
<pre>
     <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 154</span>
154:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">host_identities</span>
155:           <span class="ruby-identifier">identities</span> = []
156:           <span class="ruby-ivar">@known_host_identities</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
157: 
158:           <span class="ruby-ivar">@host_key_files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
159:             <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@key_existence_tester</span>.<span class="ruby-identifier">readable?</span>( <span class="ruby-identifier">file</span> )
160:               <span class="ruby-keyword kw">begin</span>
161:                 <span class="ruby-identifier">key</span> = <span class="ruby-ivar">@keys</span>.<span class="ruby-identifier">load_public_key</span>( <span class="ruby-identifier">file</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;.pub&quot;</span> )
162:                 <span class="ruby-identifier">identities</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">key</span>
163:                 <span class="ruby-ivar">@known_host_identities</span>[ <span class="ruby-identifier">key</span> ] =
164:                   { <span class="ruby-identifier">:from</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:file</span>, <span class="ruby-identifier">:file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">file</span> }
165:               <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
166:                 <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">warn</span> <span class="ruby-value str">&quot;could not load public host key file &quot;</span> <span class="ruby-operator">+</span>
167:                   <span class="ruby-node">&quot;'#{file}.pub' (#{e.message} [#{e.class}])&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">warn?</span>
168:               <span class="ruby-keyword kw">end</span>
169:             <span class="ruby-keyword kw">end</span>
170:           <span class="ruby-keyword kw">end</span>
171: 
172:           <span class="ruby-identifier">identities</span>
173:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000155"></a><b>identities</b>()
  </div>
  <div class="description">
  <p>
Returns an array of <a href="UserKeyManager.html#M000155">identities</a>
(public keys) known to this manager. The origin of the <a
href="UserKeyManager.html#M000155">identities</a> may be from files on disk
or from an ssh-agent. Note that <a
href="UserKeyManager.html#M000155">identities</a> from an ssh-agent are
always listed first in the array, with other <a
href="UserKeyManager.html#M000155">identities</a> coming after.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000155_source')" id="l_M000155_source">show source</a> ]</p>
  <div id="M000155_source" class="dyn-source">
<pre>
     <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 123</span>
123:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">identities</span>
124:           <span class="ruby-identifier">identities</span> = []
125:           <span class="ruby-ivar">@known_identities</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
126: 
127:           <span class="ruby-identifier">ensure_agent</span>
128:           <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@agent</span>
129:             <span class="ruby-ivar">@agent</span>.<span class="ruby-identifier">identities</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
130:               <span class="ruby-identifier">identities</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">key</span>
131:               <span class="ruby-ivar">@known_identities</span>[ <span class="ruby-identifier">key</span> ] = { <span class="ruby-identifier">:from</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:agent</span> }
132:             <span class="ruby-keyword kw">end</span>
133:           <span class="ruby-keyword kw">end</span>
134: 
135:           <span class="ruby-ivar">@key_files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
136:             <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@key_existence_tester</span>.<span class="ruby-identifier">readable?</span>( <span class="ruby-identifier">file</span> )
137:               <span class="ruby-keyword kw">begin</span>
138:                 <span class="ruby-identifier">key</span> = <span class="ruby-ivar">@keys</span>.<span class="ruby-identifier">load_public_key</span>( <span class="ruby-identifier">file</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;.pub&quot;</span> )
139:                 <span class="ruby-identifier">identities</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">key</span>
140:                 <span class="ruby-ivar">@known_identities</span>[ <span class="ruby-identifier">key</span> ] = { <span class="ruby-identifier">:from</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:file</span>, <span class="ruby-identifier">:file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">file</span> }
141:               <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
142:                 <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">warn</span> <span class="ruby-value str">&quot;could not load public key file &quot;</span> <span class="ruby-operator">+</span>
143:                   <span class="ruby-node">&quot;'#{file}.pub' (#{e.message} [#{e.class}])&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">warn?</span>
144:               <span class="ruby-keyword kw">end</span>
145:             <span class="ruby-keyword kw">end</span>
146:           <span class="ruby-keyword kw">end</span>
147: 
148:           <span class="ruby-identifier">identities</span>
149:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000157"></a><b>sign</b>( identity, data )
  </div>
  <div class="description">
  <p>
Sign the given data, using the corresponding private key of the given
identity. If the identity was originally obtained from an ssh-agent, then
the ssh-agent will be used to <a
href="UserKeyManager.html#M000157">sign</a> the data, otherwise the private
key for the identity will be loaded from disk (if it hasn&#8216;t been
loaded already) and will then be used to <a
href="UserKeyManager.html#M000157">sign</a> the data.
</p>
<p>
Regardless of the identity&#8216;s origin or who does the signing, this
will always return the signature in an SSH2-specified &quot;signature
blob&quot; format.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000157_source')" id="l_M000157_source">show source</a> ]</p>
  <div id="M000157_source" class="dyn-source">
<pre>
     <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 184</span>
184:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sign</span>( <span class="ruby-identifier">identity</span>, <span class="ruby-identifier">data</span> )
185:           <span class="ruby-identifier">info</span> = <span class="ruby-identifier">find_identity</span>( <span class="ruby-identifier">identity</span> )
186: 
187:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">info</span>[<span class="ruby-identifier">:key</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">info</span>[<span class="ruby-identifier">:from</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">:file</span>
188:             <span class="ruby-keyword kw">begin</span>
189:               <span class="ruby-identifier">info</span>[<span class="ruby-identifier">:key</span>] = <span class="ruby-ivar">@keys</span>.<span class="ruby-identifier">load_private_key</span>( <span class="ruby-identifier">info</span>[<span class="ruby-identifier">:file</span>] )
190:             <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span> 
191:               <span class="ruby-identifier">raise</span> <span class="ruby-constant">UserKeyManagerError</span>,
192:                     <span class="ruby-value str">&quot;the given identity is known, &quot;</span> <span class="ruby-operator">+</span>
193:                     <span class="ruby-value str">&quot;but the private key could not be loaded &quot;</span> <span class="ruby-operator">+</span>
194:                     <span class="ruby-node">&quot;(#{e.message} [#{e.class}])&quot;</span>
195:             <span class="ruby-keyword kw">end</span>
196:           <span class="ruby-keyword kw">end</span>
197: 
198:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">info</span>[<span class="ruby-identifier">:key</span>]
199:             <span class="ruby-identifier">sig_blob</span> = <span class="ruby-ivar">@buffers</span>.<span class="ruby-identifier">writer</span>
200:             <span class="ruby-identifier">sig_blob</span>.<span class="ruby-identifier">write_string</span> <span class="ruby-identifier">identity</span>.<span class="ruby-identifier">ssh_type</span>
201:             <span class="ruby-identifier">sig_blob</span>.<span class="ruby-identifier">write_string</span> <span class="ruby-identifier">info</span>[<span class="ruby-identifier">:key</span>].<span class="ruby-identifier">ssh_do_sign</span>( <span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_s</span> )
202:             <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">sig_blob</span>.<span class="ruby-identifier">to_s</span>
203:           <span class="ruby-keyword kw">end</span>
204: 
205:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">info</span>[<span class="ruby-identifier">:from</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">:agent</span>
206:             <span class="ruby-identifier">raise</span> <span class="ruby-constant">UserKeyManagerError</span>,
207:               <span class="ruby-value str">&quot;the agent is no longer available&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@agent</span>
208:             <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@agent</span>.<span class="ruby-identifier">sign</span>( <span class="ruby-identifier">identity</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_s</span> )
209:           <span class="ruby-keyword kw">end</span>
210: 
211:           <span class="ruby-identifier">raise</span> <span class="ruby-constant">UserKeyManagerError</span>,
212:             <span class="ruby-node">&quot;[BUG] can't determine identity origin (#{info.inspect})&quot;</span>
213:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000159"></a><b>use_agent=</b>( use_agent )
  </div>
  <div class="description">
  <p>
Toggles whether the ssh-agent will be used or not. If true, an attempt will
be made to use the ssh-agent. If false, any existing connection to an agent
is closed and the agent will not be used.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000159_source')" id="l_M000159_source">show source</a> ]</p>
  <div id="M000159_source" class="dyn-source">
<pre>
     <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 223</span>
223:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_agent=</span>( <span class="ruby-identifier">use_agent</span> )
224:           <span class="ruby-identifier">close_agent</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">use_agent</span>
225:           <span class="ruby-ivar">@use_agent</span> = <span class="ruby-identifier">use_agent</span>
226:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000158"></a><b>use_agent?</b>()
  </div>
  <div class="description">
  <p>
Identifies whether the ssh-agent will be used or not.
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000158_source')" id="l_M000158_source">show source</a> ]</p>
  <div id="M000158_source" class="dyn-source">
<pre>
     <span class="ruby-comment cmt"># File lib/net/ssh/userauth/userkeys.rb, line 216</span>
216:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_agent?</span>
217:           <span class="ruby-ivar">@use_agent</span>
218:         <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
</div>

  </div>

    </body>
</html>