• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

example/H22-Dec-2020-319234

inc/H22-Dec-2020-2,7571,908

lib/Net/H22-Dec-2020-2,7981,464

t/H22-Dec-2020-466399

ChangesH A D22-Dec-202022.4 KiB555463

MANIFESTH A D17-Apr-2020721 3736

MANIFEST.SKIPH A D17-Apr-2020233 2323

META.ymlH A D22-Dec-20201.1 KiB4746

Makefile.PLH A D22-Dec-202010 KiB331273

README.podH A D22-Dec-202023 KiB895539

SSH2.xsH A D22-Dec-202075.2 KiB2,7362,309

const-c.incH A D22-Dec-202072.5 KiB2,4402,412

const-xs.incH A D22-Dec-20202.6 KiB9190

ppport.hH A D17-Apr-2020176 KiB7,2603,105

typemapH A D17-Apr-20203.9 KiB172122

README.pod

1=pod
2
3=head1 NAME
4
5Net::SSH2 - Support for the SSH 2 protocol via libssh2.
6
7=head1 SYNOPSIS
8
9  use Net::SSH2;
10
11  my $ssh2 = Net::SSH2->new();
12
13  $ssh2->connect('example.com')
14    or $ssh2->die_with_error;
15
16  $ssh->check_hostkey('ask')
17    or $ssh2->die_with_error;
18
19  $ssh->auth_publickey($ENV{USER}, "$ENV{HOME}/.ssh/id_rsa.pub", "$ENV{HOME}/.ssh/id_rsa")
20    or $ssh->die_with_error;
21
22  my $chan = $ssh2->channel()
23    or $ssh2->die_with_error;
24
25  $chan->exec('ls')
26    or $ssh2->die_with_error;
27
28  print while <$chan>;
29
30  print "EXIT CODE: ", $chan->exit_status, "\n";
31
32  $chan->close;
33
34  my $sftp = $ssh2->sftp()
35    or $ssh2->die_with_error;;
36
37  my $fh = $sftp->open('/etc/passwd')
38    or $sftp->die_with_error;
39
40  print while <$fh>;
41
42=head1 DESCRIPTION
43
44Net::SSH2 is a Perl interface to the libssh2
45(L<http://www.libssh2.org>) library.  It supports the SSH2 protocol
46(there is no support for SSH1) with all of the key exchanges, ciphers,
47and compression of libssh2.
48
49Even if the module can be compiled and linked against very old
50versions of the library, nothing below 1.5.0 should really be used
51(older versions were quite buggy and unreliable) and version 1.7.0 or
52later is recommended.
53
54=head2 Error handling
55
56Unless otherwise indicated, methods return a true value on success and
57C<undef> on failure; use the L</error> method to get extended error
58information.
59
60B<Important>: methods in Net::SSH2 not backed by libssh2 functions
61(i.e. L</check_hostkey> or L<SCP|/scp_get> related methods) require
62libssh2 1.7.0 or later in order to set the error state. That means
63that after any of those methods fails, L</error> would not return the
64real code but just some bogus result when an older version of the
65library is used.
66
67=head2 Typical usage
68
69The typical usage order is as follows:
70
71=over 4
72
73=item 1
74
75Create the SSH2 object calling L</new>.
76
77=item 2
78
79Configure the session if required. For instance, enabling compression
80or picking some specific encryption methods.
81
82=item 3
83
84Establish the SSH connection calling the method L</connect>.
85
86=item 4
87
88Check the remote host public key calling L</check_hostkey>.
89
90=item 5
91
92Authenticate calling the required L<authentication methods|/auth>.
93
94=item 6
95
96Call L</channel> and related methods to create new bidirectional
97communication channels over the SSH connection.
98
99=item 7
100
101Close the connection letting the Net::SSH2 object go out of scope or
102calling L</disconnect> explicitly.
103
104=back
105
106=head1 CONSTANTS
107
108All the constants defined in libssh2 can be imported from
109Net::SSH2.
110
111For instance:
112
113   use Net::SSH2 qw(LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE
114                    LIBSSH2_CHANNEL_FLUSH_ALL
115                    LIBSSH2_HOSTKEY_POLICY_ASK);
116
117Though note that most methods accept the uncommon part of the
118constant name as a string. For instance the following two method calls
119are equivalent:
120
121    $channel->ext_data(LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE);
122    $channel->ext_data('merge');
123
124Tags can be used to import the following constant subsets:
125
126  callback channel error socket trace hash method
127  disconnect policy fx fxf sftp
128
129The tag C<all> can also be used to import all of them.
130
131=head1 METHODS
132
133=head2 new ( %options )
134
135Create new Net::SSH2 object representing a SSH session.
136
137The accepted options are as follows:
138
139=over 4
140
141=item timeout
142
143Sets the default timeout in milliseconds. See L</timeout>.
144
145=item trace
146
147Sets tracing. See L</trace>.
148
149Example:
150
151    my $ssh2 = Net::SSH2->new(trace => -1);
152
153Note that tracing requires a version of libssh2 compiled with debugging support.
154
155=item debug
156
157Enable debugging. See L</debug>.
158
159=item compress
160
161Sets flag C<LIBSSH2_FLAG_COMPRESS>. See L</flag>.
162
163=item sigpipe
164
165Sets flag C<LIBSSH2_FLAG_SIGPIPE>. See L</flag>.
166
167=back
168
169=head2 banner ( text )
170
171Set the SSH2 banner text sent to the remote host (prepends required "SSH-2.0-").
172
173=head2 version
174
175In scalar context, returns libssh2 version/patch e.g. 0.18 or "0.18.0-20071110".
176In list context, returns that version plus the numeric version (major, minor,
177and patch, each encoded as 8 bits, e.g. 0x001200 for version 0.18) and the
178default banner text (e.g. "SSH-2.0-libssh2_0.18.0-20071110").
179
180=head2 error
181
182Returns the last error code. In list context,
183returns (code, error name, error string).
184
185Note that the returned error value is only meaningful after some other
186method indicates an error by returning false.
187
188=head2 die_with_error ( [message] )
189
190Calls C<die> with the given message and the error information from the
191object appended.
192
193For instance:
194
195  $ssh2->connect("ajhkfhdklfjhklsjhd", 22)
196      or $ssh2->die_with_error;
197  # dies as:
198  #    Unable to connect to remote host: Invalid argument (-1 LIBSSH2_ERROR_SOCKET_NONE)
199
200=head2 sock
201
202Returns a reference to the underlying L<IO::Socket> object (usually a
203derived class as L<IO::Socket::IP> or L<IO::Socket::INET>), or
204C<undef> if not yet connected.
205
206=head2 trace
207
208Calls C<libssh2_trace> with supplied bitmask. In order to enable all
209tracing pass C<-1> as follows:
210
211    $ssh2->trace(-1);
212
213A version of libssh2 compiled with tracing support is required.
214
215=head2 timeout ( timeout_ms )
216
217Enables a global timeout (in milliseconds) which will affect every
218action (requires libssh2 1.2.9 or later).
219
220By default, or if you set the timeout to zero, Net::SSH2 has no
221timeout.
222
223Note that timeout errors may leave the SSH connection in an
224inconsistent state and further operations may fail or behave
225incorrectly. Actually, some methods are able to recover after a
226timeout error and others are not.
227
228I<Don't hesitate to report any issue you encounter related to this so
229that it can be fixed or at least, documented!>
230
231=head2 method ( type [, values... ] )
232
233Sets or gets a method preference. For get, pass in the type only; to
234set, pass in either a list of values or a comma-separated
235string. Values can only be queried after the session is connected.
236
237The following methods can be set or queried:
238
239=over 4
240
241=item LIBSSH2_METHOD_KEX
242
243Key exchange method names. Supported values:
244
245=over 4
246
247=item diffie-hellman-group1-sha1
248
249Diffie-Hellman key exchange with SHA-1 as hash, and Oakley Group 2 (see RFC
2502409).
251
252=item diffie-hellman-group14-sha1
253
254Diffie-Hellman key exchange with SHA-1 as hash, and Oakley Group 14 (see RFC
2553526).
256
257=item diffie-hellman-group-exchange-sha1
258
259Diffie-Hellman key exchange with SHA-1 as hash, using a safe-prime/generator
260pair (chosen by server) of arbitrary strength (specified by client) (see IETF
261draft secsh-dh-group-exchange).
262
263=back
264
265=item LIBSSH2_METHOD_HOSTKEY
266
267Public key algorithms. Supported values:
268
269=over 4
270
271=item ssh-dss
272
273Based on the Digital Signature Standard (FIPS-186-2).
274
275=item ssh-rsa
276
277Based on PKCS#1 (RFC 3447).
278
279=back
280
281=item LIBSSH2_METHOD_CRYPT_CS
282
283Encryption algorithm from client to server. Supported algorithms:
284
285=over 4
286
287=item aes256-cbc
288
289AES in CBC mode, with 256-bit key.
290
291=item rijndael-cbc@lysator.liu.se
292
293Alias for aes256-cbc.
294
295=item aes192-cbc
296
297AES in CBC mode, with 192-bit key.
298
299=item aes128-cbc
300
301AES in CBC mode, with 128-bit key.
302
303=item blowfish-cbc
304
305Blowfish in CBC mode.
306
307=item arcfour
308
309ARCFOUR stream cipher.
310
311=item cast128-cbc
312
313CAST-128 in CBC mode.
314
315=item 3des-cbc
316
317Three-key 3DES in CBC mode.
318
319=item none
320
321No encryption.
322
323=back
324
325=item LIBSSH2_METHOD_CRYPT_SC
326
327Encryption algorithm from server to client. See the
328C<LIBSSH2_METHOD_CRYPT_CS> entry above for supported algorithms.
329
330=item LIBSSH2_METHOD_MAC_CS
331
332Message Authentication Code (MAC) algorithms from client to server. Supported
333values:
334
335=over 4
336
337=item hmac-sha1
338
339SHA-1 with 20-byte digest and key length.
340
341=item hmac-sha1-96
342
343SHA-1 with 20-byte key length and 12-byte digest length.
344
345=item hmac-md5
346
347MD5 with 16-byte digest and key length.
348
349=item hmac-md5-96
350
351MD5 with 16-byte key length and 12-byte digest length.
352
353=item hmac-ripemd160
354
355RIPEMD-160 algorithm with 20-byte digest length.
356
357=item hmac-ripemd160@openssh.com
358
359Alias for hmac-ripemd160.
360
361=item none
362
363No encryption.
364
365=back
366
367=item LIBSSH2_METHOD_MAC_SC
368
369Message Authentication Code (MAC) algorithms from server to client. See
370L<LIBSSH2_METHOD_MAC_CS> for supported algorithms.
371
372=item LIBSSH2_METHOD_COMP_CS
373
374Compression methods from client to server. Supported values:
375
376=over 4
377
378=item zlib
379
380The "zlib" compression method as described in RFC 1950 and RFC 1951.
381
382=item none
383
384No compression
385
386=back
387
388=item LIBSSH2_METHOD_COMP_SC
389
390Compression methods from server to client. See
391L<LIBSSH2_METHOD_COMP_CS> for supported compression methods.
392
393=back
394
395=head2 connect ( handle | host [, port])
396
397The argument combinations accepted are as follows:
398
399=over 4
400
401=item a glob or C<IO::*> object reference
402
403Note that tied file handles are not acceptable. The underlying
404libssh2 requires real file handles.
405
406=item host [, port]
407
408In order to handle IPv6 addresses the optional module
409L<IO::Socket::IP> is required.
410
411The port number defaults to 22.
412
413=back
414
415This method used to accept a C<Timeout> argument. That feature has
416been replaced by the constructor C<timeout> option but note that it
417takes milliseconds instead of seconds!
418
419=head2 disconnect ( [description [, reason [, language]]] )
420
421Sends a clean disconnect message to the remote server. Default values are empty
422strings for description and language, and C<SSH_DISCONNECT_BY_APPLICATION> for
423the reason.
424
425=head2 hostname
426
427The name of the remote host given at connect time or retrieved from
428the TCP layer.
429
430=head2 port
431
432The port number of the remote SSH server.
433
434=head2 hostkey_hash ( hash type )
435
436Returns a hash of the host key; note that the key is raw data and may contain
437nulls or control characters.
438
439The type may be as follows:
440
441=over 4
442
443=item LIBSSH2_HOSTKEY_HASH_MD5
444
445MD5 hash, 16 bytes long (requires libssh2 compiled with MD5 support).
446
447=item LIBSSH2_HOSTKEY_HASH_SHA1
448
449SHA1 hash, 20 bytes long.
450
451=back
452
453Note: in previous versions of the module this method was called
454C<hostkey>.
455
456=head2 remote_hostkey
457
458Returns the public key from the remote host and its type which is one of
459C<LIBSSH2_HOSTKEY_TYPE_RSA>, C<LIBSSH2_HOSTKEY_TYPE_DSS>, or
460C<LIBSSH2_HOSTKEY_TYPE_UNKNOWN>.
461
462=head2 check_hostkey( [policy, [known_hosts_path [, comment] ] ] )
463
464Looks for the remote host key inside the given known host file
465(defaults to C<~/.ssh/known_hosts>).
466
467On success, this method returns the result of the call done under the
468hood to C<Net::SSH2::KnownHost::check>
469(i.e. C<LIBSSH2_KNOWNHOST_CHECK_MATCH>,
470C<LIBSSH2_KNOWNHOST_CHECK_FAILURE>,
471C<LIBSSH2_KNOWNHOST_CHECK_NOTFOUND> or
472C<LIBSSH2_KNOWNHOST_CHECK_MISMATCH>).
473
474On failure it returns C<undef>.
475
476The accepted policies are as follows:
477
478=over 4
479
480=item LIBSSH2_HOSTKEY_POLICY_STRICT
481
482Only host keys already present in the known hosts file are accepted.
483
484This is the default policy.
485
486=item LIBSSH2_HOSTKEY_POLICY_ASK
487
488If the host key is not present in the known hosts file, the user is
489asked if it should be accepted or not.
490
491If accepted, the key is added to the known host file with the given
492comment.
493
494=item LIBSSH2_HOSTKEY_POLICY_TOFU
495
496Trust On First Use: if the host key is not present in the known hosts
497file, it is added there and accepted.
498
499=item LIBSSH2_HOSTKEY_POLICY_ADVISORY
500
501The key is always accepted, but it is never saved into the known host
502file.
503
504=item callback
505
506If a reference to a subroutine is given, it is called when the key is
507not present in the known hosts file or a different key is found. The
508arguments passed to the callback are the session object, the matching
509error (C<LIBSSH2_KNOWNHOST_CHECK_FAILURE>,
510C<LIBSSH2_KNOWNHOST_CHECK_NOTFOUND> or
511C<LIBSSH2_KNOWNHOST_CHECK_MISMATCH>) and the comment.
512
513=back
514
515=head2 auth_list ( [username] )
516
517Returns the authentication methods accepted by the server. In scalar
518context the methods are returned as a comma separated string.
519
520When the server accepted an unauthenticated session for the given
521username, this method returns C<undef> but L</auth_ok> returns true.
522
523=head2 auth_ok
524
525Returns true when the session is authenticated.
526
527=head2 auth_password ( username [, password [, callback ]] )
528
529Authenticates using a password.
530
531If the password has expired, if a callback code reference was given, it's
532called as C<callback($self, $username)> and should return a password.  If
533no callback is provided, LIBSSH2_ERROR_PASSWORD_EXPIRED is returned.
534
535=head2 auth_password_interact ( username [, callback])
536
537Prompts the user for the password interactively (requires
538L<Term::ReadKey>).
539
540=head2 auth_publickey ( username, publickey_path, privatekey_path [, passphrase ] )
541
542Authenticate using the given private key and an optional passphrase.
543
544When libssh2 is compiled using OpenSSL as the crypto backend, passing
545this method C<undef> as the public key argument is acceptable (OpenSSL
546is able to extract the public key from the private one).
547
548See also L<Supported key formats>.
549
550=head2 auth_publickey_frommemory ( username, publickey_blob, privatekey_blob [, passphrase ] )
551
552Authenticate using the given public/private key and an optional
553passphrase. The keys must be PEM encoded (requires libssh2 1.6.0 or
554later with the OpenSSL backend).
555
556=head2 auth_hostbased ( username, publickey, privatekey, hostname,
557 [, local username [, passphrase ]] )
558
559Host-based authentication using an optional passphrase. The local username
560defaults to be the same as the remote username.
561
562=head2 auth_keyboard ( username, password | callback )
563
564Authenticate using C<keyboard-interactive>. Takes either a password,
565or a callback code reference which is invoked as
566C<callback-E<gt>(self, username, name, instruction, prompt...)> (where
567each prompt is a hash with C<text> and C<echo> keys, signifying the
568prompt text and whether the user input should be echoed, respectively)
569which should return an array of responses.
570
571If only a username is provided, the default callback will handle standard
572interactive responses (requires L<Term::ReadKey>)
573
574=head2 auth_agent ( username )
575
576Try to authenticate using an SSH agent (requires libssh2 1.2.3).
577
578=head2 auth ( ... )
579
580This is a general, prioritizing authentication mechanism that can use
581any of the previous methods. You provide it some parameters and
582(optionally) a ranked list of methods you want considered (defaults to
583all). It will remove any unsupported methods or methods for which it
584doesn't have parameters (e.g. if you don't give it a public key, it
585can't use publickey or hostkey), and try the rest, returning whichever
586one succeeded or C<undef> if they all failed. If a parameter is passed
587with an C<undef> value, a default value will be supplied if possible.
588
589The parameters are:
590
591=over 4
592
593=item rank
594
595An optional ranked list of methods to try.  The names should be the
596names of the L<Net::SSH2> C<auth> methods, e.g. C<keyboard> or
597C<publickey>, with the addition of C<keyboard-auto> for automated
598C<keyboard-interactive> and C<password-interact> which prompts the
599user for the password interactively.
600
601=item username
602
603=item password
604
605=item publickey
606
607=item privatekey
608
609C<privatekey> and C<publickey> are file paths.
610
611=item passphrase
612
613=item hostname
614
615=item local_username
616
617=item interact
618
619If this option is set to a true value, interactive methods will be enabled.
620
621=item fallback
622
623If a password is given but authentication using it fails, the module
624will fall back to ask the user for another password if this
625parameter is set to a true value.
626
627=item cb_keyboard
628
629L<auth_keyboard> callback.
630
631=item cb_password
632
633L<auth_password> callback.
634
635=back
636
637For historical reasons and in order to maintain backward compatibility
638with older versions of the module, when the C<password> argument is
639given, it is also used as the passphrase (and a deprecation warning
640generated).
641
642In order to avoid that behaviour the C<passphrase> argument must be
643also passed (it could be C<undef>). For instance:
644
645  $ssh2->auth(username => $user,
646              privatekey => $privatekey_path,
647              publickey => $publickey_path,
648              password => $password,
649              passphrase => undef);
650
651This work around will be removed in a not too distant future version
652of the module.
653
654=head2 flag (key, value)
655
656Sets the given session flag.
657
658The currently supported flag values are:
659
660=over 4
661
662=item LIBSSH2_FLAG_COMPRESS
663
664If set before the connection negotiation is performed, compression
665will be negotiated for this connection.
666
667Compression can also be enabled passing option C<compress> to the
668constructor L<new>.
669
670=item LIBSSH2_FLAG_SIGPIPE
671
672if set, Net::SSH2/libssh2 will not attempt to block SIGPIPEs but will
673let them trigger from the underlying socket layer.
674
675=back
676
677=head2 keepalive_config(want_reply, interval)
678
679Set how often keepalive messages should be sent.
680
681C<want_reply> indicates whether the keepalive messages should request
682a response from the server. C<interval> is number of seconds that can
683pass without any I/O.
684
685=head2 keepalive_send
686
687Send a keepalive message if needed.
688
689On failure returns undef. On success returns how many seconds you can
690sleep after this call before you need to call it again.
691
692Note that the underlying libssh2 function C<libssh2_keepalive_send>
693can not recover from EAGAIN errors. If this method fails with such
694error, the SSH connection may become corrupted.
695
696The usage of this function is discouraged.
697
698=head2 channel ( [type, [window size, [packet size]]] )
699
700Creates and returns a new channel object. See L<Net::SSH2::Channel>.
701
702Type, if given, must be C<session> (a reminiscence of an old, more
703generic, but never working wrapping).
704
705=head2 tcpip ( host, port [, shost, sport ] )
706
707Creates a TCP connection from the remote host to the given host:port,
708returning a new channel.
709
710The C<shost> and C<sport> arguments are merely informative and passed
711to the remote SSH server as the origin of the connection. They default
712to 127.0.0.1:22.
713
714Note that this method does B<not> open a new port on the local machine
715and forwards incoming connections to the remote side.
716
717=head2 listen ( port [, host [, bound port [, queue size ]]] )
718
719Sets up a TCP listening port on the remote host.  Host defaults to 0.0.0.0;
720if bound port is provided, it should be a scalar reference in which the bound
721port is returned. Queue size specifies the maximum number of queued connections
722allowed before the server refuses new connections.
723
724Returns a new Net::SSH2::Listener object.
725
726=head2 scp_get ( remote_path [, local_path ] )
727
728Retrieve a file with SCP. Local path defaults to basename of remote.
729
730Alternatively, C<local_path> may be an already open file handle or an
731IO::Handle object (e.g. IO::File, IO::Scalar).
732
733=head2 scp_put ( local_path [, remote_path ] )
734
735Send a file with SCP. Remote path defaults to same as local.
736
737Alternatively, C<local_path> may be an already open file handle or a
738reference to a IO::Handle object (it must have a valid stat method).
739
740=head2 sftp
741
742Return SecureFTP interface object (see L<Net::SSH2::SFTP>).
743
744Note that SFTP support in libssh2 is pretty rudimentary. You should
745consider using L<Net::SFTP::Foreign> with the L<Net::SSH2> backend
746L<Net::SFTP::Foreign::Backend::Net_SSH2> instead.
747
748=head2 public_key
749
750Return public key interface object (see L<Net::SSH2::PublicKey>).
751
752=head2 known_hosts
753
754Returns known hosts interface object (see L<Net::SSH2::KnownHosts>).
755
756=head2 poll ( timeout, arrayref of hashes )
757
758B<Deprecated>: the poll functionality in libssh2 is deprecated and
759its usage disregarded. Session methods L</sock> and
760L</block_directions> can be used instead to integrate Net::SSH2
761inside an external event loop.
762
763Pass in a timeout in milliseconds and an arrayref of hashes with the
764following keys:
765
766=over 4
767
768=item handle
769
770May be a L<Net::SSH2::Channel> or L<Net::SSH2::Listener> object, integer file
771descriptor, or perl file handle.
772
773=item events
774
775Requested events.  Combination of LIBSSH2_POLLFD_* constants (with the POLL
776prefix stripped if present), or an arrayref of the names ('in', 'hup' etc.).
777
778=item revents
779
780Returned events.  Returns a hash with the (lowercased) names of the received
781events ('in', 'hup', etc.) as keys with true values, and a C<value> key with
782the integer value.
783
784=back
785
786Returns undef on error, or the number of active objects.
787
788=head2 block_directions
789
790Get the blocked direction after some method returns
791C<LIBSSH2_ERROR_EAGAIN>.
792
793Returns C<LIBSSH2_SESSION_BLOCK_INBOUND> or/and
794C<LIBSSH2_SESSION_BLOCK_OUTBOUND>.
795
796=head2 debug ( state )
797
798Class method (affects all Net::SSH2 objects).
799
800Pass 1 to enable, 0 to disable. Debug output is sent to C<STDERR>.
801
802=head2 blocking ( flag )
803
804Enable or disable blocking.
805
806A good number of the methods in C<Net::SSH2>/C<libssh2> can not work
807in non-blocking mode. Some of them may just forcibly enable blocking
808during its execution. A few may even corrupt the SSH session or crash
809the program.
810
811The ones that can be safely called are C<read> and, with some
812caveats, C<write>. See L<Net::SSH2::Channel/write>.
813
814I<Don't hesitate to report any bug you found in that area!>
815
816=head1 INTEROPERABILITY AND OTHER KNOWN ISSUES
817
818=head2 Protocol versions
819
820The underlaying C<libssh2> library does support version 2 of the SSH
821protocol exclusively (hopefully, version 1 usage is almost extinct).
822
823The SFTP client implements version 3 of the SFTP protocol.
824
825=head2 Key formats
826
827Private and public keys can be generated and stored using different
828formats and cyphers. Which ones are accepted by C<Net::SSH2> depends
829on the libssh2 version being used and of the underlying crypto backend
830it was configured to use at build time (OpenSSL C<libssl> or
831C<libgcrypt>).
832
833An increassingly common problem is that OpenSSH since version 7.8
834(released 2018-8-24) generates keys by default using the format
835RFC4716 which is not supported by the default crypto backend
836(C<libssl>).
837
838Keys can be converted inplace to the old PEM format using
839L<ssh-keygen(1)> as follows:
840
841  $ ssh-keygen -p -m PEM -N "" -f ~/.ssh/id_rsa
842
843On Windows, PuTTYgen (which is part of the PuTTY distribution) can be
844used to convert keys.
845
846Another common issue is that in the last years OpenSSH has
847incorporated several new cyphers that are not supported by any version
848of C<libssh2> yet (though the incoming 1.8.1 may aliviate the
849situation). Currently the best option from an interoperability
850standpoint is probably to stick to RSA key usage.
851
852=head2 Security
853
854Nowadays C<libssh2> development is not thrilling; new versions (even
855minor ones) are being released just every two or three years. On the
856other hand security issues are found and reported far more
857frequently. That means that C<Net::SSH2>/C<libssh2> could be an easy
858attack vector.
859
860So, Net::SSH2 should be used only in trusted environments. More
861specifically, using it to connect to untrusted third party computers
862over the Internet is probably a very bad idea!
863
864=head1 SEE ALSO
865
866L<Net::SSH2::Channel>, L<Net::SSH2::Listener>,
867L<Net::SSH2::SFTP>, L<Net::SSH2::File>, L<Net::SSH2::Dir>.
868
869LibSSH2 documentation at L<http://www.libssh2.org>.
870
871IETF Secure Shell (secsh) working group at
872L<http://www.ietf.org/html.charters/secsh-charter.html>.
873
874L<Net::SSH::Any> and L<Net::SFTP::Foreign> integrate nicely with Net::SSH2.
875
876Other Perl modules related to SSH you may find interesting:
877L<Net::OpenSSH>, L<Net::SSH::Perl>, L<Net::OpenSSH::Parallel>,
878L<Net::OpenSSH::Compat>.
879
880=head1 COPYRIGHT AND LICENSE
881
882Copyright (C) 2005 - 2010 by David B. Robins (dbrobins@cpan.org).
883
884Copyright (C) 2010 - 2020 by Rafael Kitover (rkitover@cpan.org).
885
886Copyright (C) 2011 - 2020 by Salvador FandiE<ntilde>o (salva@cpan.org).
887
888All rights reserved.
889
890This library is free software; you can redistribute it and/or modify
891it under the same terms as Perl itself, either Perl version 5.8.0 or,
892at your option, any later version of Perl 5 you may have available.
893
894=cut
895