Net::SSH::Perl::Kex - SSH2 Key Exchange
use Net::SSH::Perl::Kex; my $kex = Net::SSH::Perl::Kex->new($ssh); $kex->exchange;
Net::SSH::Perl::Kex implements base functionality for SSH2 key exchange. The basic idea is this: Kex itself initializes the client algorithm proposal, sends it to the server, then waits for the server's proposal. From these proposals Kex chooses the algorithms that will be used in the communications between client and server (eg. encryption algorithm, MAC algorithm, etc.). Different algorithms can be used in each direction; for example, client to server communications could be encrypted using 3DES, and server to client could be encrypted using RC4.
The algorithm negotiation phase, as described above, includes negotiation for the key-exchange algorithm to be used. Currently, the only supported algorithm is Diffie-Hellman Group 1 key exchange, implemented in Net::SSH::Perl::Kex::DH1. After algorithm negotiation, the Kex object is reblessed into the key exchange class (eg. 'Net::SSH::Perl::Kex::DH1'), and then the subclass's exchange method is called to perform the key exchange.
Once control returns to Kex::exchange, the client waits for the SSH_MSG_NEWKEYS message; once received, the client turns on its incoming encryption/MAC/compression algorithms, then sends an SSH_MSG_NEWKEYS message to the server. Finally, it turns on its outgoing encryption/MAC/compression algorithms.
Please see the Net::SSH::Perl manpage for author, copyright, and license information.