1Net::SSH::Perl::Packet(U3s)er Contributed Perl DocumentatNieotn::SSH::Perl::Packet(3)
2
3
4

NAME

6       Net::SSH::Perl::Packet - Packet layer of SSH protocol
7

SYNOPSIS

9           use Net::SSH::Perl::Packet;
10
11           # Send a packet to an ssh daemon.
12           my $pack = Net::SSH::Perl::Packet->new($ssh, type => SSH_MSG_NONE);
13           $pack->send;
14
15           # Receive a packet.
16           my $pack = Net::SSH::Perl::Packet->read($ssh);
17

DESCRIPTION

19       Net::SSH::Perl::Packet implements the packet-layer piece of the SSH
20       protocol. Messages between server and client are sent as binary data
21       packets, which are encrypted (once the two sides have agreed on the
22       encryption cipher, that is).
23
24       Packets are made up primarily of a packet type, which describes the
25       type of message and data contained therein, and the data itself. In
26       addition, each packet: indicates its length in a 32-bit unsigned
27       integer; contains padding to pad the length of the packet to a multiple
28       of 8 bytes; and is verified by a 32-bit crc checksum.
29
30       Refer to the SSH RFC for more details on the packet protocol and the
31       SSH protocol in general.
32

USAGE

34   Net::SSH::Perl::Packet->new($ssh, %params)
35       Creates/starts a new packet in memory. $ssh is a Net::SSH::Perl object,
36       which should already be connected to an ssh daemon. %params can contain
37       the following keys:
38
39       ·   type
40
41           The message type of this packet. This should be one of the values
42           exported by Net::SSH::Perl::Constants from the msg tag; for
43           example, SSH_MSG_NONE.
44
45       ·   data
46
47           A Net::SSH::Perl::Buffer object containing the data in this packet.
48           Realistically, there aren't many times you'll need to supply this
49           argument: when sending a packet, it will be created automatically;
50           and when receiving a packet, the read method (see below) will
51           create the buffer automatically, as well.
52
53   Net::SSH::Perl::Packet->read($ssh)
54       Reads a packet from the ssh daemon and returns that packet.
55
56       This method will block until an entire packet has been read.  The
57       socket itself is non-blocking, but the method waits (using select) for
58       data on the incoming socket, then processes that data when it comes in.
59       If the data makes up a complete packet, the packet is returned to the
60       caller. Otherwise read continues to try to read more data.
61
62   Net::SSH::Perl::Packet->read_poll($ssh)
63       Checks the data that's been read from the sshd to see if that data
64       comprises a complete packet. If so, that packet is returned. If not,
65       returns "undef".
66
67       This method does not block.
68
69   Net::SSH::Perl::Packet->read_expect($ssh, $type)
70       Reads the next packet from the daemon and dies if the packet type does
71       not match $type. Otherwise returns the read packet.
72
73   $packet->send([ $data ])
74       Sends a packet to the ssh daemon. $data is optional, and if supplied
75       specifies the buffer to be sent in the packet (should be a
76       Net::SSH::Perl::Buffer object).  In addition, $data, if specified, must
77       include the packed message type.
78
79       If $data is not specified, send sends the buffer internal to the
80       packet, which you've presumably filled by calling the put_* methods
81       (see below).
82
83   $packet->type
84       Returns the message type of the packet $packet.
85
86   $packet->data
87       Returns the message buffer from the packet $packet; a
88       Net::SSH::Perl::Buffer object.
89
90   Net::SSH::Perl::Buffer methods
91       Calling methods from the Net::SSH::Perl::Buffer class on your
92       Net::SSH::Perl::Packet object will automatically invoke those methods
93       on the buffer object internal to your packet object (which is created
94       when your object is constructed). For example, if you executed the
95       following code:
96
97           my $packet = Net::SSH::Perl::Packet->new($ssh, type => SSH_CMSG_USER);
98           $packet->put_str($user);
99
100       this would construct a new packet object $packet, then fill its
101       internal buffer by calling the put_str method on it.
102
103       Refer to the Net::SSH::Perl::Buffer documentation (the GET AND PUT
104       METHODS section) for more details on those methods.
105

AUTHOR & COPYRIGHTS

107       Please see the Net::SSH::Perl manpage for author, copyright, and
108       license information.
109
110
111
112perl v5.32.0                      2020-07-28         Net::SSH::Perl::Packet(3)
Impressum