xref: /freebsd/crypto/openssh/PROTOCOL (revision 2f513db72b034fd5ef7f080b11be5c711c15186a)
1d4af9e69SDag-Erling SmørgravThis documents OpenSSH's deviations and extensions to the published SSH
2d4af9e69SDag-Erling Smørgravprotocol.
3d4af9e69SDag-Erling Smørgrav
4d4af9e69SDag-Erling SmørgravNote that OpenSSH's sftp and sftp-server implement revision 3 of the SSH
5d4af9e69SDag-Erling Smørgravfilexfer protocol described in:
6d4af9e69SDag-Erling Smørgrav
7ca86bcf2SDag-Erling Smørgravhttps://www.openssh.com/txt/draft-ietf-secsh-filexfer-02.txt
8d4af9e69SDag-Erling Smørgrav
9b15c8340SDag-Erling SmørgravNewer versions of the draft will not be supported, though some features
10b15c8340SDag-Erling Smørgravare individually implemented as extensions described below.
11d4af9e69SDag-Erling Smørgrav
12d4af9e69SDag-Erling SmørgravThe protocol used by OpenSSH's ssh-agent is described in the file
13d4af9e69SDag-Erling SmørgravPROTOCOL.agent
14d4af9e69SDag-Erling Smørgrav
154a421b63SDag-Erling Smørgrav1. Transport protocol changes
164a421b63SDag-Erling Smørgrav
174a421b63SDag-Erling Smørgrav1.1. transport: Protocol 2 MAC algorithm "umac-64@openssh.com"
18d4af9e69SDag-Erling Smørgrav
19d4af9e69SDag-Erling SmørgravThis is a new transport-layer MAC method using the UMAC algorithm
20d4af9e69SDag-Erling Smørgrav(rfc4418). This method is identical to the "umac-64" method documented
21d4af9e69SDag-Erling Smørgravin:
22d4af9e69SDag-Erling Smørgrav
23ca86bcf2SDag-Erling Smørgravhttps://www.openssh.com/txt/draft-miller-secsh-umac-01.txt
24d4af9e69SDag-Erling Smørgrav
254a421b63SDag-Erling Smørgrav1.2. transport: Protocol 2 compression algorithm "zlib@openssh.com"
26d4af9e69SDag-Erling Smørgrav
27d4af9e69SDag-Erling SmørgravThis transport-layer compression method uses the zlib compression
28d4af9e69SDag-Erling Smørgravalgorithm (identical to the "zlib" method in rfc4253), but delays the
29d4af9e69SDag-Erling Smørgravstart of compression until after authentication has completed. This
30d4af9e69SDag-Erling Smørgravavoids exposing compression code to attacks from unauthenticated users.
31d4af9e69SDag-Erling Smørgrav
32d4af9e69SDag-Erling SmørgravThe method is documented in:
33d4af9e69SDag-Erling Smørgrav
34ca86bcf2SDag-Erling Smørgravhttps://www.openssh.com/txt/draft-miller-secsh-compression-delayed-00.txt
35d4af9e69SDag-Erling Smørgrav
364f52dfbbSDag-Erling Smørgrav1.3. transport: New public key algorithms "ssh-rsa-cert-v01@openssh.com",
374f52dfbbSDag-Erling Smørgrav     "ssh-dsa-cert-v01@openssh.com",
384a421b63SDag-Erling Smørgrav     "ecdsa-sha2-nistp256-cert-v01@openssh.com",
394a421b63SDag-Erling Smørgrav     "ecdsa-sha2-nistp384-cert-v01@openssh.com" and
404a421b63SDag-Erling Smørgrav     "ecdsa-sha2-nistp521-cert-v01@openssh.com"
41b15c8340SDag-Erling Smørgrav
424a421b63SDag-Erling SmørgravOpenSSH introduces new public key algorithms to support certificate
43bc5531deSDag-Erling Smørgravauthentication for users and host keys. These methods are documented
44bc5531deSDag-Erling Smørgravin the file PROTOCOL.certkeys
45b15c8340SDag-Erling Smørgrav
464a421b63SDag-Erling Smørgrav1.4. transport: Elliptic Curve cryptography
474a421b63SDag-Erling Smørgrav
484a421b63SDag-Erling SmørgravOpenSSH supports ECC key exchange and public key authentication as
494a421b63SDag-Erling Smørgravspecified in RFC5656. Only the ecdsa-sha2-nistp256, ecdsa-sha2-nistp384
504a421b63SDag-Erling Smørgravand ecdsa-sha2-nistp521 curves over GF(p) are supported. Elliptic
514a421b63SDag-Erling Smørgravcurve points encoded using point compression are NOT accepted or
524a421b63SDag-Erling Smørgravgenerated.
534a421b63SDag-Erling Smørgrav
546888a9beSDag-Erling Smørgrav1.5 transport: Protocol 2 Encrypt-then-MAC MAC algorithms
556888a9beSDag-Erling Smørgrav
566888a9beSDag-Erling SmørgravOpenSSH supports MAC algorithms, whose names contain "-etm", that
576888a9beSDag-Erling Smørgravperform the calculations in a different order to that defined in RFC
586888a9beSDag-Erling Smørgrav4253. These variants use the so-called "encrypt then MAC" ordering,
596888a9beSDag-Erling Smørgravcalculating the MAC over the packet ciphertext rather than the
606888a9beSDag-Erling Smørgravplaintext. This ordering closes a security flaw in the SSH transport
616888a9beSDag-Erling Smørgravprotocol, where decryption of unauthenticated ciphertext provided a
626888a9beSDag-Erling Smørgrav"decryption oracle" that could, in conjunction with cipher flaws, reveal
636888a9beSDag-Erling Smørgravsession plaintext.
646888a9beSDag-Erling Smørgrav
656888a9beSDag-Erling SmørgravSpecifically, the "-etm" MAC algorithms modify the transport protocol
666888a9beSDag-Erling Smørgravto calculate the MAC over the packet ciphertext and to send the packet
676888a9beSDag-Erling Smørgravlength unencrypted. This is necessary for the transport to obtain the
686888a9beSDag-Erling Smørgravlength of the packet and location of the MAC tag so that it may be
696888a9beSDag-Erling Smørgravverified without decrypting unauthenticated data.
706888a9beSDag-Erling Smørgrav
716888a9beSDag-Erling SmørgravAs such, the MAC covers:
726888a9beSDag-Erling Smørgrav
736888a9beSDag-Erling Smørgrav      mac = MAC(key, sequence_number || packet_length || encrypted_packet)
746888a9beSDag-Erling Smørgrav
756888a9beSDag-Erling Smørgravwhere "packet_length" is encoded as a uint32 and "encrypted_packet"
766888a9beSDag-Erling Smørgravcontains:
776888a9beSDag-Erling Smørgrav
786888a9beSDag-Erling Smørgrav      byte      padding_length
796888a9beSDag-Erling Smørgrav      byte[n1]  payload; n1 = packet_length - padding_length - 1
806888a9beSDag-Erling Smørgrav      byte[n2]  random padding; n2 = padding_length
816888a9beSDag-Erling Smørgrav
826888a9beSDag-Erling Smørgrav1.6 transport: AES-GCM
836888a9beSDag-Erling Smørgrav
846888a9beSDag-Erling SmørgravOpenSSH supports the AES-GCM algorithm as specified in RFC 5647.
856888a9beSDag-Erling SmørgravBecause of problems with the specification of the key exchange
866888a9beSDag-Erling Smørgravthe behaviour of OpenSSH differs from the RFC as follows:
876888a9beSDag-Erling Smørgrav
886888a9beSDag-Erling SmørgravAES-GCM is only negotiated as the cipher algorithms
896888a9beSDag-Erling Smørgrav"aes128-gcm@openssh.com" or "aes256-gcm@openssh.com" and never as
906888a9beSDag-Erling Smørgravan MAC algorithm. Additionally, if AES-GCM is selected as the cipher
916888a9beSDag-Erling Smørgravthe exchanged MAC algorithms are ignored and there doesn't have to be
926888a9beSDag-Erling Smørgrava matching MAC.
936888a9beSDag-Erling Smørgrav
94f7167e0eSDag-Erling Smørgrav1.7 transport: chacha20-poly1305@openssh.com authenticated encryption
95f7167e0eSDag-Erling Smørgrav
96f7167e0eSDag-Erling SmørgravOpenSSH supports authenticated encryption using ChaCha20 and Poly1305
97f7167e0eSDag-Erling Smørgravas described in PROTOCOL.chacha20poly1305.
98f7167e0eSDag-Erling Smørgrav
99f7167e0eSDag-Erling Smørgrav1.8 transport: curve25519-sha256@libssh.org key exchange algorithm
100f7167e0eSDag-Erling Smørgrav
101f7167e0eSDag-Erling SmørgravOpenSSH supports the use of ECDH in Curve25519 for key exchange as
102f7167e0eSDag-Erling Smørgravdescribed at:
103f7167e0eSDag-Erling Smørgravhttp://git.libssh.org/users/aris/libssh.git/plain/doc/curve25519-sha256@libssh.org.txt?h=curve25519
104f7167e0eSDag-Erling Smørgrav
1054a421b63SDag-Erling Smørgrav2. Connection protocol changes
1064a421b63SDag-Erling Smørgrav
1074a421b63SDag-Erling Smørgrav2.1. connection: Channel write close extension "eow@openssh.com"
108d4af9e69SDag-Erling Smørgrav
109d4af9e69SDag-Erling SmørgravThe SSH connection protocol (rfc4254) provides the SSH_MSG_CHANNEL_EOF
110d4af9e69SDag-Erling Smørgravmessage to allow an endpoint to signal its peer that it will send no
111d4af9e69SDag-Erling Smørgravmore data over a channel. Unfortunately, there is no symmetric way for
112d4af9e69SDag-Erling Smørgravan endpoint to request that its peer should cease sending data to it
113d4af9e69SDag-Erling Smørgravwhile still keeping the channel open for the endpoint to send data to
114d4af9e69SDag-Erling Smørgravthe peer.
115d4af9e69SDag-Erling Smørgrav
116d4af9e69SDag-Erling SmørgravThis is desirable, since it saves the transmission of data that would
117d4af9e69SDag-Erling Smørgravotherwise need to be discarded and it allows an endpoint to signal local
118d4af9e69SDag-Erling Smørgravprocesses of the condition, e.g. by closing the corresponding file
119d4af9e69SDag-Erling Smørgravdescriptor.
120d4af9e69SDag-Erling Smørgrav
121d4af9e69SDag-Erling SmørgravOpenSSH implements a channel extension message to perform this
122d4af9e69SDag-Erling Smørgravsignalling: "eow@openssh.com" (End Of Write). This message is sent by
123d4af9e69SDag-Erling Smørgravan endpoint when the local output of a session channel is closed or
124d4af9e69SDag-Erling Smørgravexperiences a write error. The message is formatted as follows:
125d4af9e69SDag-Erling Smørgrav
126d4af9e69SDag-Erling Smørgrav	byte		SSH_MSG_CHANNEL_REQUEST
127d4af9e69SDag-Erling Smørgrav	uint32		recipient channel
128d4af9e69SDag-Erling Smørgrav	string		"eow@openssh.com"
129d4af9e69SDag-Erling Smørgrav	boolean		FALSE
130d4af9e69SDag-Erling Smørgrav
131d4af9e69SDag-Erling SmørgravOn receiving this message, the peer SHOULD cease sending data of
132d4af9e69SDag-Erling Smørgravthe channel and MAY signal the process from which the channel data
133d4af9e69SDag-Erling Smørgravoriginates (e.g. by closing its read file descriptor).
134d4af9e69SDag-Erling Smørgrav
135d4af9e69SDag-Erling SmørgravAs with the symmetric SSH_MSG_CHANNEL_EOF message, the channel does
136d4af9e69SDag-Erling Smørgravremain open after a "eow@openssh.com" has been sent and more data may
137d4af9e69SDag-Erling Smørgravstill be sent in the other direction. This message does not consume
138d4af9e69SDag-Erling Smørgravwindow space and may be sent even if no window space is available.
139d4af9e69SDag-Erling Smørgrav
140cce7d346SDag-Erling SmørgravNB. due to certain broken SSH implementations aborting upon receipt
141cce7d346SDag-Erling Smørgravof this message (in contravention of RFC4254 section 5.4), this
142cce7d346SDag-Erling Smørgravmessage is only sent to OpenSSH peers (identified by banner).
143cce7d346SDag-Erling SmørgravOther SSH implementations may be whitelisted to receive this message
144cce7d346SDag-Erling Smørgravupon request.
145cce7d346SDag-Erling Smørgrav
1464a421b63SDag-Erling Smørgrav2.2. connection: disallow additional sessions extension
147d4af9e69SDag-Erling Smørgrav     "no-more-sessions@openssh.com"
148d4af9e69SDag-Erling Smørgrav
149d4af9e69SDag-Erling SmørgravMost SSH connections will only ever request a single session, but a
150d4af9e69SDag-Erling Smørgravattacker may abuse a running ssh client to surreptitiously open
151d4af9e69SDag-Erling Smørgravadditional sessions under their control. OpenSSH provides a global
152d4af9e69SDag-Erling Smørgravrequest "no-more-sessions@openssh.com" to mitigate this attack.
153d4af9e69SDag-Erling Smørgrav
154d4af9e69SDag-Erling SmørgravWhen an OpenSSH client expects that it will never open another session
155d4af9e69SDag-Erling Smørgrav(i.e. it has been started with connection multiplexing disabled), it
156d4af9e69SDag-Erling Smørgravwill send the following global request:
157d4af9e69SDag-Erling Smørgrav
158d4af9e69SDag-Erling Smørgrav	byte		SSH_MSG_GLOBAL_REQUEST
159d4af9e69SDag-Erling Smørgrav	string		"no-more-sessions@openssh.com"
160d4af9e69SDag-Erling Smørgrav	char		want-reply
161d4af9e69SDag-Erling Smørgrav
162d4af9e69SDag-Erling SmørgravOn receipt of such a message, an OpenSSH server will refuse to open
163d4af9e69SDag-Erling Smørgravfuture channels of type "session" and instead immediately abort the
164d4af9e69SDag-Erling Smørgravconnection.
165d4af9e69SDag-Erling Smørgrav
166d4af9e69SDag-Erling SmørgravNote that this is not a general defence against compromised clients
167d4af9e69SDag-Erling Smørgrav(that is impossible), but it thwarts a simple attack.
168d4af9e69SDag-Erling Smørgrav
169cce7d346SDag-Erling SmørgravNB. due to certain broken SSH implementations aborting upon receipt
170cce7d346SDag-Erling Smørgravof this message, the no-more-sessions request is only sent to OpenSSH
171cce7d346SDag-Erling Smørgravservers (identified by banner). Other SSH implementations may be
172cce7d346SDag-Erling Smørgravwhitelisted to receive this message upon request.
173cce7d346SDag-Erling Smørgrav
1744a421b63SDag-Erling Smørgrav2.3. connection: Tunnel forward extension "tun@openssh.com"
175d4af9e69SDag-Erling Smørgrav
176d4af9e69SDag-Erling SmørgravOpenSSH supports layer 2 and layer 3 tunnelling via the "tun@openssh.com"
177d4af9e69SDag-Erling Smørgravchannel type. This channel type supports forwarding of network packets
178d4af9e69SDag-Erling Smørgravwith datagram boundaries intact between endpoints equipped with
179d4af9e69SDag-Erling Smørgravinterfaces like the BSD tun(4) device. Tunnel forwarding channels are
180d4af9e69SDag-Erling Smørgravrequested by the client with the following packet:
181d4af9e69SDag-Erling Smørgrav
182d4af9e69SDag-Erling Smørgrav	byte		SSH_MSG_CHANNEL_OPEN
183d4af9e69SDag-Erling Smørgrav	string		"tun@openssh.com"
184d4af9e69SDag-Erling Smørgrav	uint32		sender channel
185d4af9e69SDag-Erling Smørgrav	uint32		initial window size
186d4af9e69SDag-Erling Smørgrav	uint32		maximum packet size
187d4af9e69SDag-Erling Smørgrav	uint32		tunnel mode
188d4af9e69SDag-Erling Smørgrav	uint32		remote unit number
189d4af9e69SDag-Erling Smørgrav
190d4af9e69SDag-Erling SmørgravThe "tunnel mode" parameter specifies whether the tunnel should forward
191d4af9e69SDag-Erling Smørgravlayer 2 frames or layer 3 packets. It may take one of the following values:
192d4af9e69SDag-Erling Smørgrav
193d4af9e69SDag-Erling Smørgrav	SSH_TUNMODE_POINTOPOINT  1		/* layer 3 packets */
194d4af9e69SDag-Erling Smørgrav	SSH_TUNMODE_ETHERNET     2		/* layer 2 frames */
195d4af9e69SDag-Erling Smørgrav
196d4af9e69SDag-Erling SmørgravThe "tunnel unit number" specifies the remote interface number, or may
197b15c8340SDag-Erling Smørgravbe 0x7fffffff to allow the server to automatically chose an interface. A
198b15c8340SDag-Erling Smørgravserver that is not willing to open a client-specified unit should refuse
199b15c8340SDag-Erling Smørgravthe request with a SSH_MSG_CHANNEL_OPEN_FAILURE error. On successful
200b15c8340SDag-Erling Smørgravopen, the server should reply with SSH_MSG_CHANNEL_OPEN_SUCCESS.
201d4af9e69SDag-Erling Smørgrav
202d4af9e69SDag-Erling SmørgravOnce established the client and server may exchange packet or frames
203d4af9e69SDag-Erling Smørgravover the tunnel channel by encapsulating them in SSH protocol strings
204d4af9e69SDag-Erling Smørgravand sending them as channel data. This ensures that packet boundaries
205d4af9e69SDag-Erling Smørgravare kept intact. Specifically, packets are transmitted using normal
206d4af9e69SDag-Erling SmørgravSSH_MSG_CHANNEL_DATA packets:
207d4af9e69SDag-Erling Smørgrav
208d4af9e69SDag-Erling Smørgrav	byte		SSH_MSG_CHANNEL_DATA
209d4af9e69SDag-Erling Smørgrav	uint32		recipient channel
210d4af9e69SDag-Erling Smørgrav	string		data
211d4af9e69SDag-Erling Smørgrav
212d4af9e69SDag-Erling SmørgravThe contents of the "data" field for layer 3 packets is:
213d4af9e69SDag-Erling Smørgrav
214d4af9e69SDag-Erling Smørgrav	uint32			packet length
215d4af9e69SDag-Erling Smørgrav	uint32			address family
216d4af9e69SDag-Erling Smørgrav	byte[packet length - 4]	packet data
217d4af9e69SDag-Erling Smørgrav
218d4af9e69SDag-Erling SmørgravThe "address family" field identifies the type of packet in the message.
219d4af9e69SDag-Erling SmørgravIt may be one of:
220d4af9e69SDag-Erling Smørgrav
221d4af9e69SDag-Erling Smørgrav	SSH_TUN_AF_INET		2		/* IPv4 */
222d4af9e69SDag-Erling Smørgrav	SSH_TUN_AF_INET6	24		/* IPv6 */
223d4af9e69SDag-Erling Smørgrav
224d4af9e69SDag-Erling SmørgravThe "packet data" field consists of the IPv4/IPv6 datagram itself
225d4af9e69SDag-Erling Smørgravwithout any link layer header.
226d4af9e69SDag-Erling Smørgrav
227b15c8340SDag-Erling SmørgravThe contents of the "data" field for layer 2 packets is:
228d4af9e69SDag-Erling Smørgrav
229d4af9e69SDag-Erling Smørgrav	uint32			packet length
230d4af9e69SDag-Erling Smørgrav	byte[packet length]	frame
231d4af9e69SDag-Erling Smørgrav
232d4af9e69SDag-Erling SmørgravThe "frame" field contains an IEEE 802.3 Ethernet frame, including
233d4af9e69SDag-Erling Smørgravheader.
234d4af9e69SDag-Erling Smørgrav
235a0ee8cc6SDag-Erling Smørgrav2.4. connection: Unix domain socket forwarding
236a0ee8cc6SDag-Erling Smørgrav
237a0ee8cc6SDag-Erling SmørgravOpenSSH supports local and remote Unix domain socket forwarding
238a0ee8cc6SDag-Erling Smørgravusing the "streamlocal" extension.  Forwarding is initiated as per
239a0ee8cc6SDag-Erling SmørgravTCP sockets but with a single path instead of a host and port.
240a0ee8cc6SDag-Erling Smørgrav
241a0ee8cc6SDag-Erling SmørgravSimilar to direct-tcpip, direct-streamlocal is sent by the client
242a0ee8cc6SDag-Erling Smørgravto request that the server make a connection to a Unix domain socket.
243a0ee8cc6SDag-Erling Smørgrav
244a0ee8cc6SDag-Erling Smørgrav	byte		SSH_MSG_CHANNEL_OPEN
245a0ee8cc6SDag-Erling Smørgrav	string		"direct-streamlocal@openssh.com"
246a0ee8cc6SDag-Erling Smørgrav	uint32		sender channel
247a0ee8cc6SDag-Erling Smørgrav	uint32		initial window size
248a0ee8cc6SDag-Erling Smørgrav	uint32		maximum packet size
249a0ee8cc6SDag-Erling Smørgrav	string		socket path
250076ad2f8SDag-Erling Smørgrav	string		reserved
251076ad2f8SDag-Erling Smørgrav	uint32		reserved
252a0ee8cc6SDag-Erling Smørgrav
253a0ee8cc6SDag-Erling SmørgravSimilar to forwarded-tcpip, forwarded-streamlocal is sent by the
254a0ee8cc6SDag-Erling Smørgravserver when the client has previously send the server a streamlocal-forward
255a0ee8cc6SDag-Erling SmørgravGLOBAL_REQUEST.
256a0ee8cc6SDag-Erling Smørgrav
257a0ee8cc6SDag-Erling Smørgrav	byte		SSH_MSG_CHANNEL_OPEN
258a0ee8cc6SDag-Erling Smørgrav	string		"forwarded-streamlocal@openssh.com"
259a0ee8cc6SDag-Erling Smørgrav	uint32		sender channel
260a0ee8cc6SDag-Erling Smørgrav	uint32		initial window size
261a0ee8cc6SDag-Erling Smørgrav	uint32		maximum packet size
262a0ee8cc6SDag-Erling Smørgrav	string		socket path
263a0ee8cc6SDag-Erling Smørgrav	string		reserved for future use
264a0ee8cc6SDag-Erling Smørgrav
265a0ee8cc6SDag-Erling SmørgravThe reserved field is not currently defined and is ignored on the
266a0ee8cc6SDag-Erling Smørgravremote end.  It is intended to be used in the future to pass
267a0ee8cc6SDag-Erling Smørgravinformation about the socket file, such as ownership and mode.
268a0ee8cc6SDag-Erling SmørgravThe client currently sends the empty string for this field.
269a0ee8cc6SDag-Erling Smørgrav
270a0ee8cc6SDag-Erling SmørgravSimilar to tcpip-forward, streamlocal-forward is sent by the client
271a0ee8cc6SDag-Erling Smørgravto request remote forwarding of a Unix domain socket.
272a0ee8cc6SDag-Erling Smørgrav
273a0ee8cc6SDag-Erling Smørgrav	byte		SSH2_MSG_GLOBAL_REQUEST
274a0ee8cc6SDag-Erling Smørgrav	string		"streamlocal-forward@openssh.com"
275a0ee8cc6SDag-Erling Smørgrav	boolean		TRUE
276a0ee8cc6SDag-Erling Smørgrav	string		socket path
277a0ee8cc6SDag-Erling Smørgrav
278a0ee8cc6SDag-Erling SmørgravSimilar to cancel-tcpip-forward, cancel-streamlocal-forward is sent
279a0ee8cc6SDag-Erling Smørgravby the client cancel the forwarding of a Unix domain socket.
280a0ee8cc6SDag-Erling Smørgrav
281a0ee8cc6SDag-Erling Smørgrav	byte		SSH2_MSG_GLOBAL_REQUEST
282a0ee8cc6SDag-Erling Smørgrav	string		"cancel-streamlocal-forward@openssh.com"
283a0ee8cc6SDag-Erling Smørgrav	boolean		FALSE
284a0ee8cc6SDag-Erling Smørgrav	string		socket path
285a0ee8cc6SDag-Erling Smørgrav
286bc5531deSDag-Erling Smørgrav2.5. connection: hostkey update and rotation "hostkeys-00@openssh.com"
287bc5531deSDag-Erling Smørgravand "hostkeys-prove-00@openssh.com"
288bc5531deSDag-Erling Smørgrav
289bc5531deSDag-Erling SmørgravOpenSSH supports a protocol extension allowing a server to inform
290bc5531deSDag-Erling Smørgrava client of all its protocol v.2 host keys after user-authentication
291bc5531deSDag-Erling Smørgravhas completed.
292bc5531deSDag-Erling Smørgrav
293bc5531deSDag-Erling Smørgrav	byte		SSH_MSG_GLOBAL_REQUEST
294bc5531deSDag-Erling Smørgrav	string		"hostkeys-00@openssh.com"
295bc5531deSDag-Erling Smørgrav	string[]	hostkeys
296bc5531deSDag-Erling Smørgrav
297bc5531deSDag-Erling SmørgravUpon receiving this message, a client should check which of the
29847dd1d1bSDag-Erling Smørgravsupplied host keys are present in known_hosts.
29947dd1d1bSDag-Erling Smørgrav
30047dd1d1bSDag-Erling SmørgravNote that the server may send key types that the client does not
30147dd1d1bSDag-Erling Smørgravsupport. The client should disgregard such keys if they are received.
30247dd1d1bSDag-Erling Smørgrav
30347dd1d1bSDag-Erling SmørgravIf the client identifies any keys that are not present for the host,
30447dd1d1bSDag-Erling Smørgravit should send a "hostkeys-prove@openssh.com" message to request the
30547dd1d1bSDag-Erling Smørgravserver prove ownership of the private half of the key.
306bc5531deSDag-Erling Smørgrav
307bc5531deSDag-Erling Smørgrav	byte		SSH_MSG_GLOBAL_REQUEST
308bc5531deSDag-Erling Smørgrav	string		"hostkeys-prove-00@openssh.com"
309bc5531deSDag-Erling Smørgrav	char		1 /* want-reply */
310bc5531deSDag-Erling Smørgrav	string[]	hostkeys
311bc5531deSDag-Erling Smørgrav
312bc5531deSDag-Erling SmørgravWhen a server receives this message, it should generate a signature
313bc5531deSDag-Erling Smørgravusing each requested key over the following:
314bc5531deSDag-Erling Smørgrav
315bc5531deSDag-Erling Smørgrav	string		"hostkeys-prove-00@openssh.com"
316bc5531deSDag-Erling Smørgrav	string		session identifier
317bc5531deSDag-Erling Smørgrav	string		hostkey
318bc5531deSDag-Erling Smørgrav
319bc5531deSDag-Erling SmørgravThese signatures should be included in the reply, in the order matching
320bc5531deSDag-Erling Smørgravthe hostkeys in the request:
321bc5531deSDag-Erling Smørgrav
322bc5531deSDag-Erling Smørgrav	byte		SSH_MSG_REQUEST_SUCCESS
323bc5531deSDag-Erling Smørgrav	string[]	signatures
324bc5531deSDag-Erling Smørgrav
325bc5531deSDag-Erling SmørgravWhen the client receives this reply (and not a failure), it should
326bc5531deSDag-Erling Smørgravvalidate the signatures and may update its known_hosts file, adding keys
327bc5531deSDag-Erling Smørgravthat it has not seen before and deleting keys for the server host that
328bc5531deSDag-Erling Smørgravare no longer offered.
329bc5531deSDag-Erling Smørgrav
330bc5531deSDag-Erling SmørgravThese extensions let a client learn key types that it had not previously
331bc5531deSDag-Erling Smørgravencountered, thereby allowing it to potentially upgrade from weaker
332bc5531deSDag-Erling Smørgravkey algorithms to better ones. It also supports graceful key rotation:
333bc5531deSDag-Erling Smørgrava server may offer multiple keys of the same type for a period (to
334bc5531deSDag-Erling Smørgravgive clients an opportunity to learn them using this extension) before
335bc5531deSDag-Erling Smørgravremoving the deprecated key from those offered.
336bc5531deSDag-Erling Smørgrav
337*2f513db7SEd Maste2.6. connection: SIGINFO support for "signal" channel request
338*2f513db7SEd Maste
339*2f513db7SEd MasteThe SSH channels protocol (RFC4254 section 6.9) supports sending a
340*2f513db7SEd Mastesignal to a session attached to a channel. OpenSSH supports one
341*2f513db7SEd Masteextension signal "INFO@openssh.com" that allows sending SIGINFO on
342*2f513db7SEd MasteBSD-derived systems.
343*2f513db7SEd Maste
3444a421b63SDag-Erling Smørgrav3. SFTP protocol changes
3454a421b63SDag-Erling Smørgrav
3464a421b63SDag-Erling Smørgrav3.1. sftp: Reversal of arguments to SSH_FXP_SYMLINK
347d4af9e69SDag-Erling Smørgrav
348d4af9e69SDag-Erling SmørgravWhen OpenSSH's sftp-server was implemented, the order of the arguments
349d4af9e69SDag-Erling Smørgravto the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately,
350d4af9e69SDag-Erling Smørgravthe reversal was not noticed until the server was widely deployed. Since
351d4af9e69SDag-Erling Smørgravfixing this to follow the specification would cause incompatibility, the
352d4af9e69SDag-Erling Smørgravcurrent order was retained. For correct operation, clients should send
353d4af9e69SDag-Erling SmørgravSSH_FXP_SYMLINK as follows:
354d4af9e69SDag-Erling Smørgrav
355d4af9e69SDag-Erling Smørgrav	uint32		id
356d4af9e69SDag-Erling Smørgrav	string		targetpath
357d4af9e69SDag-Erling Smørgrav	string		linkpath
358d4af9e69SDag-Erling Smørgrav
3594a421b63SDag-Erling Smørgrav3.2. sftp: Server extension announcement in SSH_FXP_VERSION
360d4af9e69SDag-Erling Smørgrav
361d4af9e69SDag-Erling SmørgravOpenSSH's sftp-server lists the extensions it supports using the
362d4af9e69SDag-Erling Smørgravstandard extension announcement mechanism in the SSH_FXP_VERSION server
363d4af9e69SDag-Erling Smørgravhello packet:
364d4af9e69SDag-Erling Smørgrav
365d4af9e69SDag-Erling Smørgrav	uint32		3		/* protocol version */
366d4af9e69SDag-Erling Smørgrav	string		ext1-name
367d4af9e69SDag-Erling Smørgrav	string		ext1-version
368d4af9e69SDag-Erling Smørgrav	string		ext2-name
369d4af9e69SDag-Erling Smørgrav	string		ext2-version
370d4af9e69SDag-Erling Smørgrav	...
371d4af9e69SDag-Erling Smørgrav	string		extN-name
372d4af9e69SDag-Erling Smørgrav	string		extN-version
373d4af9e69SDag-Erling Smørgrav
374d4af9e69SDag-Erling SmørgravEach extension reports its integer version number as an ASCII encoded
375d4af9e69SDag-Erling Smørgravstring, e.g. "1". The version will be incremented if the extension is
376d4af9e69SDag-Erling Smørgravever changed in an incompatible way. The server MAY advertise the same
377d4af9e69SDag-Erling Smørgravextension with multiple versions (though this is unlikely). Clients MUST
378d4af9e69SDag-Erling Smørgravcheck the version number before attempting to use the extension.
379d4af9e69SDag-Erling Smørgrav
3804a421b63SDag-Erling Smørgrav3.3. sftp: Extension request "posix-rename@openssh.com"
381d4af9e69SDag-Erling Smørgrav
382d4af9e69SDag-Erling SmørgravThis operation provides a rename operation with POSIX semantics, which
383d4af9e69SDag-Erling Smørgravare different to those provided by the standard SSH_FXP_RENAME in
384d4af9e69SDag-Erling Smørgravdraft-ietf-secsh-filexfer-02.txt. This request is implemented as a
385d4af9e69SDag-Erling SmørgravSSH_FXP_EXTENDED request with the following format:
386d4af9e69SDag-Erling Smørgrav
387d4af9e69SDag-Erling Smørgrav	uint32		id
388d4af9e69SDag-Erling Smørgrav	string		"posix-rename@openssh.com"
389d4af9e69SDag-Erling Smørgrav	string		oldpath
390d4af9e69SDag-Erling Smørgrav	string		newpath
391d4af9e69SDag-Erling Smørgrav
392d4af9e69SDag-Erling SmørgravOn receiving this request the server will perform the POSIX operation
393d4af9e69SDag-Erling Smørgravrename(oldpath, newpath) and will respond with a SSH_FXP_STATUS message.
394d4af9e69SDag-Erling SmørgravThis extension is advertised in the SSH_FXP_VERSION hello with version
395d4af9e69SDag-Erling Smørgrav"1".
396d4af9e69SDag-Erling Smørgrav
3974a421b63SDag-Erling Smørgrav3.4. sftp: Extension requests "statvfs@openssh.com" and
398d4af9e69SDag-Erling Smørgrav         "fstatvfs@openssh.com"
399d4af9e69SDag-Erling Smørgrav
400d4af9e69SDag-Erling SmørgravThese requests correspond to the statvfs and fstatvfs POSIX system
401d4af9e69SDag-Erling Smørgravinterfaces. The "statvfs@openssh.com" request operates on an explicit
402d4af9e69SDag-Erling Smørgravpathname, and is formatted as follows:
403d4af9e69SDag-Erling Smørgrav
404d4af9e69SDag-Erling Smørgrav	uint32		id
405d4af9e69SDag-Erling Smørgrav	string		"statvfs@openssh.com"
406d4af9e69SDag-Erling Smørgrav	string		path
407d4af9e69SDag-Erling Smørgrav
408d4af9e69SDag-Erling SmørgravThe "fstatvfs@openssh.com" operates on an open file handle:
409d4af9e69SDag-Erling Smørgrav
410d4af9e69SDag-Erling Smørgrav	uint32		id
411d4af9e69SDag-Erling Smørgrav	string		"fstatvfs@openssh.com"
412d4af9e69SDag-Erling Smørgrav	string		handle
413d4af9e69SDag-Erling Smørgrav
414d4af9e69SDag-Erling SmørgravThese requests return a SSH_FXP_STATUS reply on failure. On success they
415d4af9e69SDag-Erling Smørgravreturn the following SSH_FXP_EXTENDED_REPLY reply:
416d4af9e69SDag-Erling Smørgrav
417d4af9e69SDag-Erling Smørgrav	uint32		id
418d4af9e69SDag-Erling Smørgrav	uint64		f_bsize		/* file system block size */
419d4af9e69SDag-Erling Smørgrav	uint64		f_frsize	/* fundamental fs block size */
420d4af9e69SDag-Erling Smørgrav	uint64		f_blocks	/* number of blocks (unit f_frsize) */
421d4af9e69SDag-Erling Smørgrav	uint64		f_bfree		/* free blocks in file system */
422d4af9e69SDag-Erling Smørgrav	uint64		f_bavail	/* free blocks for non-root */
423d4af9e69SDag-Erling Smørgrav	uint64		f_files		/* total file inodes */
424d4af9e69SDag-Erling Smørgrav	uint64		f_ffree		/* free file inodes */
425d4af9e69SDag-Erling Smørgrav	uint64		f_favail	/* free file inodes for to non-root */
426d4af9e69SDag-Erling Smørgrav	uint64		f_fsid		/* file system id */
427d4af9e69SDag-Erling Smørgrav	uint64		f_flag		/* bit mask of f_flag values */
428d4af9e69SDag-Erling Smørgrav	uint64		f_namemax	/* maximum filename length */
429d4af9e69SDag-Erling Smørgrav
430d4af9e69SDag-Erling SmørgravThe values of the f_flag bitmask are as follows:
431d4af9e69SDag-Erling Smørgrav
432d4af9e69SDag-Erling Smørgrav	#define SSH_FXE_STATVFS_ST_RDONLY	0x1	/* read-only */
433d4af9e69SDag-Erling Smørgrav	#define SSH_FXE_STATVFS_ST_NOSUID	0x2	/* no setuid */
434d4af9e69SDag-Erling Smørgrav
435d4af9e69SDag-Erling SmørgravBoth the "statvfs@openssh.com" and "fstatvfs@openssh.com" extensions are
436d4af9e69SDag-Erling Smørgravadvertised in the SSH_FXP_VERSION hello with version "2".
437d4af9e69SDag-Erling Smørgrav
438190cef3dSDag-Erling Smørgrav3.5. sftp: Extension request "hardlink@openssh.com"
4394a421b63SDag-Erling Smørgrav
4404a421b63SDag-Erling SmørgravThis request is for creating a hard link to a regular file. This
4414a421b63SDag-Erling Smørgravrequest is implemented as a SSH_FXP_EXTENDED request with the
4424a421b63SDag-Erling Smørgravfollowing format:
4434a421b63SDag-Erling Smørgrav
4444a421b63SDag-Erling Smørgrav	uint32		id
4454a421b63SDag-Erling Smørgrav	string		"hardlink@openssh.com"
4464a421b63SDag-Erling Smørgrav	string		oldpath
4474a421b63SDag-Erling Smørgrav	string		newpath
4484a421b63SDag-Erling Smørgrav
4494a421b63SDag-Erling SmørgravOn receiving this request the server will perform the operation
4504a421b63SDag-Erling Smørgravlink(oldpath, newpath) and will respond with a SSH_FXP_STATUS message.
4514a421b63SDag-Erling SmørgravThis extension is advertised in the SSH_FXP_VERSION hello with version
4524a421b63SDag-Erling Smørgrav"1".
4534a421b63SDag-Erling Smørgrav
454190cef3dSDag-Erling Smørgrav3.6. sftp: Extension request "fsync@openssh.com"
455f7167e0eSDag-Erling Smørgrav
456f7167e0eSDag-Erling SmørgravThis request asks the server to call fsync(2) on an open file handle.
457f7167e0eSDag-Erling Smørgrav
458f7167e0eSDag-Erling Smørgrav	uint32		id
459f7167e0eSDag-Erling Smørgrav	string		"fsync@openssh.com"
460f7167e0eSDag-Erling Smørgrav	string		handle
461f7167e0eSDag-Erling Smørgrav
462f7167e0eSDag-Erling SmørgravOne receiving this request, a server will call fsync(handle_fd) and will
463f7167e0eSDag-Erling Smørgravrespond with a SSH_FXP_STATUS message.
464f7167e0eSDag-Erling Smørgrav
465f7167e0eSDag-Erling SmørgravThis extension is advertised in the SSH_FXP_VERSION hello with version
466f7167e0eSDag-Erling Smørgrav"1".
467f7167e0eSDag-Erling Smørgrav
468190cef3dSDag-Erling Smørgrav4. Miscellaneous changes
469190cef3dSDag-Erling Smørgrav
470190cef3dSDag-Erling Smørgrav4.1 Public key format
471190cef3dSDag-Erling Smørgrav
472190cef3dSDag-Erling SmørgravOpenSSH public keys, as generated by ssh-keygen(1) and appearing in
473190cef3dSDag-Erling Smørgravauthorized_keys files, are formatted as a single line of text consisting
474190cef3dSDag-Erling Smørgravof the public key algorithm name followed by a base64-encoded key blob.
475190cef3dSDag-Erling SmørgravThe public key blob (before base64 encoding) is the same format used for
476190cef3dSDag-Erling Smørgravthe encoding of public keys sent on the wire: as described in RFC4253
477190cef3dSDag-Erling Smørgravsection 6.6 for RSA and DSA keys, RFC5656 section 3.1 for ECDSA keys
478190cef3dSDag-Erling Smørgravand the "New public key formats" section of PROTOCOL.certkeys for the
479190cef3dSDag-Erling SmørgravOpenSSH certificate formats.
480190cef3dSDag-Erling Smørgrav
481190cef3dSDag-Erling Smørgrav4.2 Private key format
482190cef3dSDag-Erling Smørgrav
483190cef3dSDag-Erling SmørgravOpenSSH private keys, as generated by ssh-keygen(1) use the format
484190cef3dSDag-Erling Smørgravdescribed in PROTOCOL.key by default. As a legacy option, PEM format
485190cef3dSDag-Erling Smørgrav(RFC7468) private keys are also supported for RSA, DSA and ECDSA keys
486190cef3dSDag-Erling Smørgravand were the default format before OpenSSH 7.8.
487190cef3dSDag-Erling Smørgrav
488190cef3dSDag-Erling Smørgrav4.3 KRL format
489190cef3dSDag-Erling Smørgrav
490190cef3dSDag-Erling SmørgravOpenSSH supports a compact format for Key Revocation Lists (KRLs). This
491190cef3dSDag-Erling Smørgravformat is described in the PROTOCOL.krl file.
492190cef3dSDag-Erling Smørgrav
493190cef3dSDag-Erling Smørgrav4.4 Connection multiplexing
494190cef3dSDag-Erling Smørgrav
495190cef3dSDag-Erling SmørgravOpenSSH's connection multiplexing uses messages as described in
496190cef3dSDag-Erling SmørgravPROTOCOL.mux over a Unix domain socket for communications between a
497190cef3dSDag-Erling Smørgravmaster instance and later clients.
498190cef3dSDag-Erling Smørgrav
499*2f513db7SEd Maste$OpenBSD: PROTOCOL,v 1.36 2018/10/02 12:51:58 djm Exp $
500