xref: /openbsd/usr.bin/ssh/PROTOCOL (revision 56f6b460)
1422225e8SdjmThis documents OpenSSH's deviations and extensions to the published SSH
2422225e8Sdjmprotocol.
3422225e8Sdjm
438d4658eSdjmNote that OpenSSH's sftp and sftp-server implement revision 3 of the SSH
538d4658eSdjmfilexfer protocol described in:
6422225e8Sdjm
7422225e8Sdjmhttp://www.openssh.com/txt/draft-ietf-secsh-filexfer-02.txt
8422225e8Sdjm
9f452f5c5SdjmNewer versions of the draft will not be supported, though some features
10f452f5c5Sdjmare individually implemented as extensions described below.
11422225e8Sdjm
12f0c9babeSdjmThe protocol used by OpenSSH's ssh-agent is described in the file
13f0c9babeSdjmPROTOCOL.agent
14f0c9babeSdjm
15f6c05033Sdjm1. Transport protocol changes
16f6c05033Sdjm
17f6c05033Sdjm1.1. transport: Protocol 2 MAC algorithm "umac-64@openssh.com"
18422225e8Sdjm
19422225e8SdjmThis is a new transport-layer MAC method using the UMAC algorithm
20422225e8Sdjm(rfc4418). This method is identical to the "umac-64" method documented
21422225e8Sdjmin:
22422225e8Sdjm
23422225e8Sdjmhttp://www.openssh.com/txt/draft-miller-secsh-umac-01.txt
24422225e8Sdjm
25f6c05033Sdjm1.2. transport: Protocol 2 compression algorithm "zlib@openssh.com"
26422225e8Sdjm
27422225e8SdjmThis transport-layer compression method uses the zlib compression
28422225e8Sdjmalgorithm (identical to the "zlib" method in rfc4253), but delays the
29422225e8Sdjmstart of compression until after authentication has completed. This
3038d4658eSdjmavoids exposing compression code to attacks from unauthenticated users.
31422225e8Sdjm
32422225e8SdjmThe method is documented in:
33422225e8Sdjm
34422225e8Sdjmhttp://www.openssh.com/txt/draft-miller-secsh-compression-delayed-00.txt
35422225e8Sdjm
369d14aae5Sdjm1.3. transport: New public key algorithms "ssh-rsa-cert-v01@openssh.com",
379d14aae5Sdjm     "ssh-dsa-cert-v01@openssh.com",
38f6c05033Sdjm     "ecdsa-sha2-nistp256-cert-v01@openssh.com",
39f6c05033Sdjm     "ecdsa-sha2-nistp384-cert-v01@openssh.com" and
40f6c05033Sdjm     "ecdsa-sha2-nistp521-cert-v01@openssh.com"
41b94e498eSdjm
42f6c05033SdjmOpenSSH introduces new public key algorithms to support certificate
4383fcfd69Sdjmauthentication for users and host keys. These methods are documented
4483fcfd69Sdjmin the file PROTOCOL.certkeys
45b94e498eSdjm
46f6c05033Sdjm1.4. transport: Elliptic Curve cryptography
47f6c05033Sdjm
48f6c05033SdjmOpenSSH supports ECC key exchange and public key authentication as
49f6c05033Sdjmspecified in RFC5656. Only the ecdsa-sha2-nistp256, ecdsa-sha2-nistp384
50f6c05033Sdjmand ecdsa-sha2-nistp521 curves over GF(p) are supported. Elliptic
51f6c05033Sdjmcurve points encoded using point compression are NOT accepted or
52f6c05033Sdjmgenerated.
53f6c05033Sdjm
54c2ea1f0aSmarkus1.5 transport: Protocol 2 Encrypt-then-MAC MAC algorithms
55c2ea1f0aSmarkus
56c2ea1f0aSmarkusOpenSSH supports MAC algorithms, whose names contain "-etm", that
57c2ea1f0aSmarkusperform the calculations in a different order to that defined in RFC
58c2ea1f0aSmarkus4253. These variants use the so-called "encrypt then MAC" ordering,
59c2ea1f0aSmarkuscalculating the MAC over the packet ciphertext rather than the
60c2ea1f0aSmarkusplaintext. This ordering closes a security flaw in the SSH transport
61c2ea1f0aSmarkusprotocol, where decryption of unauthenticated ciphertext provided a
62c2ea1f0aSmarkus"decryption oracle" that could, in conjunction with cipher flaws, reveal
63c2ea1f0aSmarkussession plaintext.
64c2ea1f0aSmarkus
65c2ea1f0aSmarkusSpecifically, the "-etm" MAC algorithms modify the transport protocol
66c2ea1f0aSmarkusto calculate the MAC over the packet ciphertext and to send the packet
67c2ea1f0aSmarkuslength unencrypted. This is necessary for the transport to obtain the
68c2ea1f0aSmarkuslength of the packet and location of the MAC tag so that it may be
69c2ea1f0aSmarkusverified without decrypting unauthenticated data.
70c2ea1f0aSmarkus
71c2ea1f0aSmarkusAs such, the MAC covers:
72c2ea1f0aSmarkus
734ea77511Sdjm      mac = MAC(key, sequence_number || packet_length || encrypted_packet)
74c2ea1f0aSmarkus
754ea77511Sdjmwhere "packet_length" is encoded as a uint32 and "encrypted_packet"
764ea77511Sdjmcontains:
77c2ea1f0aSmarkus
78c2ea1f0aSmarkus      byte      padding_length
79c2ea1f0aSmarkus      byte[n1]  payload; n1 = packet_length - padding_length - 1
80c2ea1f0aSmarkus      byte[n2]  random padding; n2 = padding_length
81c2ea1f0aSmarkus
8247da1b19Smarkus1.6 transport: AES-GCM
8347da1b19Smarkus
8447da1b19SmarkusOpenSSH supports the AES-GCM algorithm as specified in RFC 5647.
8547da1b19SmarkusBecause of problems with the specification of the key exchange
8647da1b19Smarkusthe behaviour of OpenSSH differs from the RFC as follows:
8747da1b19Smarkus
8847da1b19SmarkusAES-GCM is only negotiated as the cipher algorithms
8947da1b19Smarkus"aes128-gcm@openssh.com" or "aes256-gcm@openssh.com" and never as
9047da1b19Smarkusan MAC algorithm. Additionally, if AES-GCM is selected as the cipher
9147da1b19Smarkusthe exchanged MAC algorithms are ignored and there doesn't have to be
9247da1b19Smarkusa matching MAC.
9347da1b19Smarkus
941edbfe23Sdjm1.7 transport: chacha20-poly1305@openssh.com authenticated encryption
951edbfe23Sdjm
961edbfe23SdjmOpenSSH supports authenticated encryption using ChaCha20 and Poly1305
971edbfe23Sdjmas described in PROTOCOL.chacha20poly1305.
981edbfe23Sdjm
99f4da7defSdjm1.8 transport: curve25519-sha256@libssh.org key exchange algorithm
100f4da7defSdjm
101f4da7defSdjmOpenSSH supports the use of ECDH in Curve25519 for key exchange as
102f4da7defSdjmdescribed at:
103f4da7defSdjmhttp://git.libssh.org/users/aris/libssh.git/plain/doc/curve25519-sha256@libssh.org.txt?h=curve25519
104f4da7defSdjm
1055f2fb3a3SdtuckerThis is identical to curve25519-sha256 as later published in RFC8731.
1065f2fb3a3Sdtucker
107*56f6b460Sdjm1.9 transport: ping facility
108*56f6b460Sdjm
109*56f6b460SdjmOpenSSH implements a transport level ping message SSH2_MSG_PING
110*56f6b460Sdjmand a corresponding SSH2_MSG_PONG reply.
111*56f6b460Sdjm
112*56f6b460Sdjm#define SSH2_MSG_PING	192
113*56f6b460Sdjm#define SSH2_MSG_PONG	193
114*56f6b460Sdjm
115*56f6b460SdjmThe ping message is simply:
116*56f6b460Sdjm
117*56f6b460Sdjm	byte		SSH_MSG_PING
118*56f6b460Sdjm	string		data
119*56f6b460Sdjm
120*56f6b460SdjmThe reply copies the data (which may be the empty string) from the
121*56f6b460Sdjmping:
122*56f6b460Sdjm
123*56f6b460Sdjm	byte		SSH_MSG_PONG
124*56f6b460Sdjm	string		data
125*56f6b460Sdjm
126*56f6b460SdjmReplies are sent in order. They are sent immediately except when rekeying
127*56f6b460Sdjmis in progress, in which case they are queued until rekeying completes.
128*56f6b460Sdjm
129*56f6b460SdjmThe server advertises support for these messages using the
130*56f6b460SdjmSSH2_MSG_EXT_INFO mechanism (RFC8308), with the following message:
131*56f6b460Sdjm
132*56f6b460Sdjm	string		"ping@openssh.com"
133*56f6b460Sdjm	string		"0" (version)
134*56f6b460Sdjm
135*56f6b460SdjmThe ping/reply message is implemented at the transport layer rather
136*56f6b460Sdjmthan as a named global or channel request to allow pings with very
137*56f6b460Sdjmshort packet lengths, which would not be possible with other
138*56f6b460Sdjmapproaches.
139*56f6b460Sdjm
140f6c05033Sdjm2. Connection protocol changes
141f6c05033Sdjm
142f6c05033Sdjm2.1. connection: Channel write close extension "eow@openssh.com"
143422225e8Sdjm
144422225e8SdjmThe SSH connection protocol (rfc4254) provides the SSH_MSG_CHANNEL_EOF
145422225e8Sdjmmessage to allow an endpoint to signal its peer that it will send no
146422225e8Sdjmmore data over a channel. Unfortunately, there is no symmetric way for
147422225e8Sdjman endpoint to request that its peer should cease sending data to it
148422225e8Sdjmwhile still keeping the channel open for the endpoint to send data to
149422225e8Sdjmthe peer.
150422225e8Sdjm
15138d4658eSdjmThis is desirable, since it saves the transmission of data that would
152422225e8Sdjmotherwise need to be discarded and it allows an endpoint to signal local
153422225e8Sdjmprocesses of the condition, e.g. by closing the corresponding file
154422225e8Sdjmdescriptor.
155422225e8Sdjm
156422225e8SdjmOpenSSH implements a channel extension message to perform this
1577153c228Sdjmsignalling: "eow@openssh.com" (End Of Write). This message is sent by
1587153c228Sdjman endpoint when the local output of a session channel is closed or
1597153c228Sdjmexperiences a write error. The message is formatted as follows:
160422225e8Sdjm
161422225e8Sdjm	byte		SSH_MSG_CHANNEL_REQUEST
162422225e8Sdjm	uint32		recipient channel
163422225e8Sdjm	string		"eow@openssh.com"
164422225e8Sdjm	boolean		FALSE
165422225e8Sdjm
166422225e8SdjmOn receiving this message, the peer SHOULD cease sending data of
167422225e8Sdjmthe channel and MAY signal the process from which the channel data
168422225e8Sdjmoriginates (e.g. by closing its read file descriptor).
169422225e8Sdjm
170422225e8SdjmAs with the symmetric SSH_MSG_CHANNEL_EOF message, the channel does
171422225e8Sdjmremain open after a "eow@openssh.com" has been sent and more data may
172422225e8Sdjmstill be sent in the other direction. This message does not consume
173422225e8Sdjmwindow space and may be sent even if no window space is available.
174422225e8Sdjm
175e187e146SdjmNB. due to certain broken SSH implementations aborting upon receipt
176e187e146Sdjmof this message (in contravention of RFC4254 section 5.4), this
177e187e146Sdjmmessage is only sent to OpenSSH peers (identified by banner).
1785bde2954SdjmOther SSH implementations may be listed to receive this message
179e187e146Sdjmupon request.
180e187e146Sdjm
181f6c05033Sdjm2.2. connection: disallow additional sessions extension
18282046f86Sdjm     "no-more-sessions@openssh.com"
18382046f86Sdjm
18482046f86SdjmMost SSH connections will only ever request a single session, but a
18582046f86Sdjmattacker may abuse a running ssh client to surreptitiously open
18682046f86Sdjmadditional sessions under their control. OpenSSH provides a global
18782046f86Sdjmrequest "no-more-sessions@openssh.com" to mitigate this attack.
18882046f86Sdjm
18982046f86SdjmWhen an OpenSSH client expects that it will never open another session
19082046f86Sdjm(i.e. it has been started with connection multiplexing disabled), it
19182046f86Sdjmwill send the following global request:
19282046f86Sdjm
19382046f86Sdjm	byte		SSH_MSG_GLOBAL_REQUEST
19482046f86Sdjm	string		"no-more-sessions@openssh.com"
19582046f86Sdjm	char		want-reply
19682046f86Sdjm
19782046f86SdjmOn receipt of such a message, an OpenSSH server will refuse to open
19882046f86Sdjmfuture channels of type "session" and instead immediately abort the
19982046f86Sdjmconnection.
20082046f86Sdjm
20182046f86SdjmNote that this is not a general defence against compromised clients
20282046f86Sdjm(that is impossible), but it thwarts a simple attack.
20382046f86Sdjm
204e187e146SdjmNB. due to certain broken SSH implementations aborting upon receipt
205e187e146Sdjmof this message, the no-more-sessions request is only sent to OpenSSH
206e187e146Sdjmservers (identified by banner). Other SSH implementations may be
2075bde2954Sdjmlisted to receive this message upon request.
208e187e146Sdjm
209f6c05033Sdjm2.3. connection: Tunnel forward extension "tun@openssh.com"
2100afb9521Sdjm
2116c9c8648SdjmOpenSSH supports layer 2 and layer 3 tunnelling via the "tun@openssh.com"
2120afb9521Sdjmchannel type. This channel type supports forwarding of network packets
2136c9c8648Sdjmwith datagram boundaries intact between endpoints equipped with
2140afb9521Sdjminterfaces like the BSD tun(4) device. Tunnel forwarding channels are
2150afb9521Sdjmrequested by the client with the following packet:
2160afb9521Sdjm
2170afb9521Sdjm	byte		SSH_MSG_CHANNEL_OPEN
2180afb9521Sdjm	string		"tun@openssh.com"
2190afb9521Sdjm	uint32		sender channel
2200afb9521Sdjm	uint32		initial window size
2210afb9521Sdjm	uint32		maximum packet size
2220afb9521Sdjm	uint32		tunnel mode
2230afb9521Sdjm	uint32		remote unit number
2240afb9521Sdjm
2250afb9521SdjmThe "tunnel mode" parameter specifies whether the tunnel should forward
2260afb9521Sdjmlayer 2 frames or layer 3 packets. It may take one of the following values:
2270afb9521Sdjm
2280afb9521Sdjm	SSH_TUNMODE_POINTOPOINT  1		/* layer 3 packets */
2290afb9521Sdjm	SSH_TUNMODE_ETHERNET     2		/* layer 2 frames */
2300afb9521Sdjm
2310afb9521SdjmThe "tunnel unit number" specifies the remote interface number, or may
23238ea1073Sdtuckerbe 0x7fffffff to allow the server to automatically choose an interface. A
233c880fb56Sdjmserver that is not willing to open a client-specified unit should refuse
234c880fb56Sdjmthe request with a SSH_MSG_CHANNEL_OPEN_FAILURE error. On successful
235c880fb56Sdjmopen, the server should reply with SSH_MSG_CHANNEL_OPEN_SUCCESS.
2360afb9521Sdjm
2370afb9521SdjmOnce established the client and server may exchange packet or frames
2380afb9521Sdjmover the tunnel channel by encapsulating them in SSH protocol strings
2390afb9521Sdjmand sending them as channel data. This ensures that packet boundaries
2400afb9521Sdjmare kept intact. Specifically, packets are transmitted using normal
2410afb9521SdjmSSH_MSG_CHANNEL_DATA packets:
2420afb9521Sdjm
2430afb9521Sdjm	byte		SSH_MSG_CHANNEL_DATA
2440afb9521Sdjm	uint32		recipient channel
2450afb9521Sdjm	string		data
2460afb9521Sdjm
2470afb9521SdjmThe contents of the "data" field for layer 3 packets is:
2480afb9521Sdjm
2490afb9521Sdjm	uint32			packet length
2500afb9521Sdjm	uint32			address family
2510afb9521Sdjm	byte[packet length - 4]	packet data
2520afb9521Sdjm
2530afb9521SdjmThe "address family" field identifies the type of packet in the message.
2540afb9521SdjmIt may be one of:
2550afb9521Sdjm
2560afb9521Sdjm	SSH_TUN_AF_INET		2		/* IPv4 */
2570afb9521Sdjm	SSH_TUN_AF_INET6	24		/* IPv6 */
2580afb9521Sdjm
2590afb9521SdjmThe "packet data" field consists of the IPv4/IPv6 datagram itself
2600afb9521Sdjmwithout any link layer header.
2610afb9521Sdjm
262c880fb56SdjmThe contents of the "data" field for layer 2 packets is:
2630afb9521Sdjm
2640afb9521Sdjm	uint32			packet length
2650afb9521Sdjm	byte[packet length]	frame
2660afb9521Sdjm
2676c9c8648SdjmThe "frame" field contains an IEEE 802.3 Ethernet frame, including
2680afb9521Sdjmheader.
2690afb9521Sdjm
270a0215499Smillert2.4. connection: Unix domain socket forwarding
271a0215499Smillert
272a0215499SmillertOpenSSH supports local and remote Unix domain socket forwarding
273a0215499Smillertusing the "streamlocal" extension.  Forwarding is initiated as per
274a0215499SmillertTCP sockets but with a single path instead of a host and port.
275a0215499Smillert
276a0215499SmillertSimilar to direct-tcpip, direct-streamlocal is sent by the client
277a0215499Smillertto request that the server make a connection to a Unix domain socket.
278a0215499Smillert
279a0215499Smillert	byte		SSH_MSG_CHANNEL_OPEN
280a0215499Smillert	string		"direct-streamlocal@openssh.com"
281a0215499Smillert	uint32		sender channel
282a0215499Smillert	uint32		initial window size
283a0215499Smillert	uint32		maximum packet size
284a0215499Smillert	string		socket path
2853e584310Sdjm	string		reserved
2863e584310Sdjm	uint32		reserved
287a0215499Smillert
288a0215499SmillertSimilar to forwarded-tcpip, forwarded-streamlocal is sent by the
289a0215499Smillertserver when the client has previously send the server a streamlocal-forward
290a0215499SmillertGLOBAL_REQUEST.
291a0215499Smillert
292a0215499Smillert	byte		SSH_MSG_CHANNEL_OPEN
293a0215499Smillert	string		"forwarded-streamlocal@openssh.com"
294a0215499Smillert	uint32		sender channel
295a0215499Smillert	uint32		initial window size
296a0215499Smillert	uint32		maximum packet size
297a0215499Smillert	string		socket path
298a0215499Smillert	string		reserved for future use
299a0215499Smillert
300a0215499SmillertThe reserved field is not currently defined and is ignored on the
301a0215499Smillertremote end.  It is intended to be used in the future to pass
302a0215499Smillertinformation about the socket file, such as ownership and mode.
303a0215499SmillertThe client currently sends the empty string for this field.
304a0215499Smillert
305a0215499SmillertSimilar to tcpip-forward, streamlocal-forward is sent by the client
306a0215499Smillertto request remote forwarding of a Unix domain socket.
307a0215499Smillert
308a0215499Smillert	byte		SSH2_MSG_GLOBAL_REQUEST
309a0215499Smillert	string		"streamlocal-forward@openssh.com"
310a0215499Smillert	boolean		TRUE
311a0215499Smillert	string		socket path
312a0215499Smillert
313a0215499SmillertSimilar to cancel-tcpip-forward, cancel-streamlocal-forward is sent
314a0215499Smillertby the client cancel the forwarding of a Unix domain socket.
315a0215499Smillert
316a0215499Smillert	byte		SSH2_MSG_GLOBAL_REQUEST
317a0215499Smillert	string		"cancel-streamlocal-forward@openssh.com"
318a0215499Smillert	boolean		FALSE
319a0215499Smillert	string		socket path
320a0215499Smillert
3213782b423Sdjm2.5. connection: hostkey update and rotation "hostkeys-00@openssh.com"
3223782b423Sdjmand "hostkeys-prove-00@openssh.com"
32306c9be66Sdjm
32406c9be66SdjmOpenSSH supports a protocol extension allowing a server to inform
32506c9be66Sdjma client of all its protocol v.2 host keys after user-authentication
32606c9be66Sdjmhas completed.
32706c9be66Sdjm
32806c9be66Sdjm	byte		SSH_MSG_GLOBAL_REQUEST
3293782b423Sdjm	string		"hostkeys-00@openssh.com"
3302514f071Sdjm	char		0 /* want-reply */
33106c9be66Sdjm	string[]	hostkeys
33206c9be66Sdjm
33383fcfd69SdjmUpon receiving this message, a client should check which of the
33461185547Sdjmsupplied host keys are present in known_hosts.
33561185547Sdjm
33661185547SdjmNote that the server may send key types that the client does not
33738ea1073Sdtuckersupport. The client should disregard such keys if they are received.
33861185547Sdjm
33961185547SdjmIf the client identifies any keys that are not present for the host,
34061185547Sdjmit should send a "hostkeys-prove@openssh.com" message to request the
34161185547Sdjmserver prove ownership of the private half of the key.
34206c9be66Sdjm
34383fcfd69Sdjm	byte		SSH_MSG_GLOBAL_REQUEST
3443782b423Sdjm	string		"hostkeys-prove-00@openssh.com"
34583fcfd69Sdjm	char		1 /* want-reply */
34683fcfd69Sdjm	string[]	hostkeys
34783fcfd69Sdjm
34883fcfd69SdjmWhen a server receives this message, it should generate a signature
34983fcfd69Sdjmusing each requested key over the following:
35083fcfd69Sdjm
3513782b423Sdjm	string		"hostkeys-prove-00@openssh.com"
35283fcfd69Sdjm	string		session identifier
35383fcfd69Sdjm	string		hostkey
35483fcfd69Sdjm
35583fcfd69SdjmThese signatures should be included in the reply, in the order matching
35683fcfd69Sdjmthe hostkeys in the request:
35783fcfd69Sdjm
35883fcfd69Sdjm	byte		SSH_MSG_REQUEST_SUCCESS
35983fcfd69Sdjm	string[]	signatures
36083fcfd69Sdjm
36183fcfd69SdjmWhen the client receives this reply (and not a failure), it should
36283fcfd69Sdjmvalidate the signatures and may update its known_hosts file, adding keys
36383fcfd69Sdjmthat it has not seen before and deleting keys for the server host that
36483fcfd69Sdjmare no longer offered.
36583fcfd69Sdjm
36683fcfd69SdjmThese extensions let a client learn key types that it had not previously
36783fcfd69Sdjmencountered, thereby allowing it to potentially upgrade from weaker
36883fcfd69Sdjmkey algorithms to better ones. It also supports graceful key rotation:
36983fcfd69Sdjma server may offer multiple keys of the same type for a period (to
37083fcfd69Sdjmgive clients an opportunity to learn them using this extension) before
37183fcfd69Sdjmremoving the deprecated key from those offered.
37206c9be66Sdjm
373a098558bSdjm2.6. connection: SIGINFO support for "signal" channel request
374a098558bSdjm
375a098558bSdjmThe SSH channels protocol (RFC4254 section 6.9) supports sending a
376a098558bSdjmsignal to a session attached to a channel. OpenSSH supports one
377a098558bSdjmextension signal "INFO@openssh.com" that allows sending SIGINFO on
378a098558bSdjmBSD-derived systems.
379a098558bSdjm
380caafdf97Sdjm3. Authentication protocol changes
381f6c05033Sdjm
382caafdf97Sdjm3.1. Host-bound public key authentication
383caafdf97Sdjm
384caafdf97SdjmThis is trivial change to the traditional "publickey" authentication
385caafdf97Sdjmmethod. The authentication request is identical to the original method
386caafdf97Sdjmbut for the name and one additional field:
387caafdf97Sdjm
388caafdf97Sdjm	byte		SSH2_MSG_USERAUTH_REQUEST
389caafdf97Sdjm	string		username
390caafdf97Sdjm	string		"ssh-connection"
391caafdf97Sdjm	string		"publickey-hostbound-v00@openssh.com"
392caafdf97Sdjm	bool		has_signature
393caafdf97Sdjm	string		pkalg
394caafdf97Sdjm	string		public key
395caafdf97Sdjm	string		server host key
396caafdf97Sdjm
397caafdf97SdjmBecause the entire SSH2_MSG_USERAUTH_REQUEST message is included in
398caafdf97Sdjmthe signed data, this ensures that a binding between the destination
399caafdf97Sdjmuser, the server identity and the session identifier is visible to the
400caafdf97Sdjmsigner. OpenSSH uses this binding via signed data to implement per-key
401caafdf97Sdjmrestrictions in ssh-agent.
402caafdf97Sdjm
403caafdf97SdjmA server may advertise this method using the SSH2_MSG_EXT_INFO
404caafdf97Sdjmmechanism (RFC8308), with the following message:
405caafdf97Sdjm
406caafdf97Sdjm	string		"publickey-hostbound@openssh.com"
407caafdf97Sdjm	string		"0" (version)
408caafdf97Sdjm
409caafdf97SdjmClients should prefer host-bound authentication when advertised by
410caafdf97Sdjmserver.
411caafdf97Sdjm
412caafdf97Sdjm4. SFTP protocol changes
413caafdf97Sdjm
414caafdf97Sdjm4.1. sftp: Reversal of arguments to SSH_FXP_SYMLINK
415422225e8Sdjm
416422225e8SdjmWhen OpenSSH's sftp-server was implemented, the order of the arguments
4176c9c8648Sdjmto the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately,
418422225e8Sdjmthe reversal was not noticed until the server was widely deployed. Since
419422225e8Sdjmfixing this to follow the specification would cause incompatibility, the
420422225e8Sdjmcurrent order was retained. For correct operation, clients should send
421422225e8SdjmSSH_FXP_SYMLINK as follows:
422422225e8Sdjm
423422225e8Sdjm	uint32		id
424422225e8Sdjm	string		targetpath
425422225e8Sdjm	string		linkpath
426422225e8Sdjm
427caafdf97Sdjm4.2. sftp: Server extension announcement in SSH_FXP_VERSION
428422225e8Sdjm
429422225e8SdjmOpenSSH's sftp-server lists the extensions it supports using the
430422225e8Sdjmstandard extension announcement mechanism in the SSH_FXP_VERSION server
431422225e8Sdjmhello packet:
432422225e8Sdjm
433422225e8Sdjm	uint32		3		/* protocol version */
434422225e8Sdjm	string		ext1-name
435422225e8Sdjm	string		ext1-version
436422225e8Sdjm	string		ext2-name
437422225e8Sdjm	string		ext2-version
438422225e8Sdjm	...
439422225e8Sdjm	string		extN-name
440422225e8Sdjm	string		extN-version
441422225e8Sdjm
442422225e8SdjmEach extension reports its integer version number as an ASCII encoded
443422225e8Sdjmstring, e.g. "1". The version will be incremented if the extension is
444422225e8Sdjmever changed in an incompatible way. The server MAY advertise the same
445422225e8Sdjmextension with multiple versions (though this is unlikely). Clients MUST
4466c9c8648Sdjmcheck the version number before attempting to use the extension.
447422225e8Sdjm
448caafdf97Sdjm4.3. sftp: Extension request "posix-rename@openssh.com"
449422225e8Sdjm
450422225e8SdjmThis operation provides a rename operation with POSIX semantics, which
451422225e8Sdjmare different to those provided by the standard SSH_FXP_RENAME in
452422225e8Sdjmdraft-ietf-secsh-filexfer-02.txt. This request is implemented as a
453422225e8SdjmSSH_FXP_EXTENDED request with the following format:
454422225e8Sdjm
455422225e8Sdjm	uint32		id
456422225e8Sdjm	string		"posix-rename@openssh.com"
457422225e8Sdjm	string		oldpath
458422225e8Sdjm	string		newpath
459422225e8Sdjm
460422225e8SdjmOn receiving this request the server will perform the POSIX operation
461422225e8Sdjmrename(oldpath, newpath) and will respond with a SSH_FXP_STATUS message.
462422225e8SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
463422225e8Sdjm"1".
464422225e8Sdjm
465caafdf97Sdjm4.4. sftp: Extension requests "statvfs@openssh.com" and
466422225e8Sdjm         "fstatvfs@openssh.com"
467422225e8Sdjm
468422225e8SdjmThese requests correspond to the statvfs and fstatvfs POSIX system
469422225e8Sdjminterfaces. The "statvfs@openssh.com" request operates on an explicit
470422225e8Sdjmpathname, and is formatted as follows:
471422225e8Sdjm
472422225e8Sdjm	uint32		id
473422225e8Sdjm	string		"statvfs@openssh.com"
474422225e8Sdjm	string		path
475422225e8Sdjm
476422225e8SdjmThe "fstatvfs@openssh.com" operates on an open file handle:
477422225e8Sdjm
478422225e8Sdjm	uint32		id
47938d4658eSdjm	string		"fstatvfs@openssh.com"
480422225e8Sdjm	string		handle
481422225e8Sdjm
482422225e8SdjmThese requests return a SSH_FXP_STATUS reply on failure. On success they
483422225e8Sdjmreturn the following SSH_FXP_EXTENDED_REPLY reply:
484422225e8Sdjm
485422225e8Sdjm	uint32		id
486f00164cfSdtucker	uint64		f_bsize		/* file system block size */
487f00164cfSdtucker	uint64		f_frsize	/* fundamental fs block size */
488422225e8Sdjm	uint64		f_blocks	/* number of blocks (unit f_frsize) */
489422225e8Sdjm	uint64		f_bfree		/* free blocks in file system */
490422225e8Sdjm	uint64		f_bavail	/* free blocks for non-root */
491422225e8Sdjm	uint64		f_files		/* total file inodes */
492422225e8Sdjm	uint64		f_ffree		/* free file inodes */
493422225e8Sdjm	uint64		f_favail	/* free file inodes for to non-root */
49433745cbfSdjm	uint64		f_fsid		/* file system id */
495f00164cfSdtucker	uint64		f_flag		/* bit mask of f_flag values */
496f00164cfSdtucker	uint64		f_namemax	/* maximum filename length */
497422225e8Sdjm
498422225e8SdjmThe values of the f_flag bitmask are as follows:
499422225e8Sdjm
500422225e8Sdjm	#define SSH_FXE_STATVFS_ST_RDONLY	0x1	/* read-only */
501422225e8Sdjm	#define SSH_FXE_STATVFS_ST_NOSUID	0x2	/* no setuid */
502422225e8Sdjm
503fae5684aSdjmBoth the "statvfs@openssh.com" and "fstatvfs@openssh.com" extensions are
504fae5684aSdjmadvertised in the SSH_FXP_VERSION hello with version "2".
50533745cbfSdjm
506caafdf97Sdjm4.5. sftp: Extension request "hardlink@openssh.com"
5079c120764Sdjm
5089c120764SdjmThis request is for creating a hard link to a regular file. This
5099c120764Sdjmrequest is implemented as a SSH_FXP_EXTENDED request with the
5109c120764Sdjmfollowing format:
5119c120764Sdjm
5129c120764Sdjm	uint32		id
5139c120764Sdjm	string		"hardlink@openssh.com"
5149c120764Sdjm	string		oldpath
5159c120764Sdjm	string		newpath
5169c120764Sdjm
5179c120764SdjmOn receiving this request the server will perform the operation
5189c120764Sdjmlink(oldpath, newpath) and will respond with a SSH_FXP_STATUS message.
5199c120764SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
5209c120764Sdjm"1".
5219c120764Sdjm
522caafdf97Sdjm4.6. sftp: Extension request "fsync@openssh.com"
52394e35841Sdjm
52494e35841SdjmThis request asks the server to call fsync(2) on an open file handle.
52594e35841Sdjm
52694e35841Sdjm	uint32		id
52794e35841Sdjm	string		"fsync@openssh.com"
52894e35841Sdjm	string		handle
52994e35841Sdjm
5302ac6810fSdjmOn receiving this request, a server will call fsync(handle_fd) and will
53194e35841Sdjmrespond with a SSH_FXP_STATUS message.
53294e35841Sdjm
53394e35841SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
53494e35841Sdjm"1".
53594e35841Sdjm
536caafdf97Sdjm4.7. sftp: Extension request "lsetstat@openssh.com"
5374dc35148Sdjm
5384dc35148SdjmThis request is like the "setstat" command, but sets file attributes on
5394dc35148Sdjmsymlinks.  It is implemented as a SSH_FXP_EXTENDED request with the
5404dc35148Sdjmfollowing format:
5414dc35148Sdjm
5424dc35148Sdjm	uint32		id
5434dc35148Sdjm	string		"lsetstat@openssh.com"
5444dc35148Sdjm	string		path
5454dc35148Sdjm	ATTRS		attrs
5464dc35148Sdjm
5474dc35148SdjmSee the "setstat" command for more details.
5484dc35148Sdjm
5494dc35148SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
5504dc35148Sdjm"1".
5514dc35148Sdjm
552caafdf97Sdjm4.8. sftp: Extension request "limits@openssh.com"
553029b49a0Sdjm
554029b49a0SdjmThis request is used to determine various limits the server might impose.
555029b49a0SdjmClients should not attempt to exceed these limits as the server might sever
556029b49a0Sdjmthe connection immediately.
557029b49a0Sdjm
558029b49a0Sdjm	uint32		id
559029b49a0Sdjm	string		"limits@openssh.com"
560029b49a0Sdjm
561029b49a0SdjmThe server will respond with a SSH_FXP_EXTENDED_REPLY reply:
562029b49a0Sdjm
563029b49a0Sdjm	uint32		id
564029b49a0Sdjm	uint64		max-packet-length
565029b49a0Sdjm	uint64		max-read-length
566029b49a0Sdjm	uint64		max-write-length
567029b49a0Sdjm	uint64		max-open-handles
568029b49a0Sdjm
569029b49a0SdjmThe 'max-packet-length' applies to the total number of bytes in a
570029b49a0Sdjmsingle SFTP packet.  Servers SHOULD set this at least to 34000.
571029b49a0Sdjm
572029b49a0SdjmThe 'max-read-length' is the largest length in a SSH_FXP_READ packet.
573029b49a0SdjmEven if the client requests a larger size, servers will usually respond
574029b49a0Sdjmwith a shorter SSH_FXP_DATA packet.  Servers SHOULD set this at least to
575029b49a0Sdjm32768.
576029b49a0Sdjm
577029b49a0SdjmThe 'max-write-length' is the largest length in a SSH_FXP_WRITE packet
578029b49a0Sdjmthe server will accept.  Servers SHOULD set this at least to 32768.
579029b49a0Sdjm
580029b49a0SdjmThe 'max-open-handles' is the maximum number of active handles that the
581029b49a0Sdjmserver allows (e.g. handles created by SSH_FXP_OPEN and SSH_FXP_OPENDIR
582029b49a0Sdjmpackets).  Servers MAY count internal file handles against this limit
583029b49a0Sdjm(e.g. system logging or stdout/stderr), so clients SHOULD NOT expect to
584029b49a0Sdjmopen this many handles in practice.
585029b49a0Sdjm
586029b49a0SdjmIf the server doesn't enforce a specific limit, then the field may be
587029b49a0Sdjmset to 0.  This implies the server relies on the OS to enforce limits
588029b49a0Sdjm(e.g. available memory or file handles), and such limits might be
589029b49a0Sdjmdynamic.  The client SHOULD take care to not try to exceed reasonable
590029b49a0Sdjmlimits.
591029b49a0Sdjm
592029b49a0SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
593029b49a0Sdjm"1".
594029b49a0Sdjm
595caafdf97Sdjm4.9. sftp: Extension request "expand-path@openssh.com"
596e4383b47Sdjm
597e4383b47SdjmThis request supports canonicalisation of relative paths and
598e4383b47Sdjmthose that need tilde-expansion, i.e. "~", "~/..." and "~user/..."
599e4383b47SdjmThese paths are expanded using shell-like rules and the resultant
600e4383b47Sdjmpath is canonicalised similarly to SSH2_FXP_REALPATH.
601e4383b47Sdjm
602e4383b47SdjmIt is implemented as a SSH_FXP_EXTENDED request with the following
603e4383b47Sdjmformat:
604e4383b47Sdjm
605e4383b47Sdjm	uint32		id
606e4383b47Sdjm	string		"expand-path@openssh.com"
607e4383b47Sdjm	string		path
608e4383b47Sdjm
609e4383b47SdjmIts reply is the same format as that of SSH2_FXP_REALPATH.
610e4383b47Sdjm
611e4383b47SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
612e4383b47Sdjm"1".
613e4383b47Sdjm
6142ac6810fSdjm4.10. sftp: Extension request "copy-data"
6152ac6810fSdjm
6162ac6810fSdjmThis request asks the server to copy data from one open file handle and
6172ac6810fSdjmwrite it to a different open file handle.  This avoids needing to transfer
6182ac6810fSdjmthe data across the network twice (a download followed by an upload).
6192ac6810fSdjm
6202ac6810fSdjm	byte		SSH_FXP_EXTENDED
6212ac6810fSdjm	uint32		id
6222ac6810fSdjm	string		"copy-data"
6232ac6810fSdjm	string		read-from-handle
6242ac6810fSdjm	uint64		read-from-offset
6252ac6810fSdjm	uint64		read-data-length
6262ac6810fSdjm	string		write-to-handle
6272ac6810fSdjm	uint64		write-to-offset
6282ac6810fSdjm
6292ac6810fSdjmThe server will copy read-data-length bytes starting from
6302ac6810fSdjmread-from-offset from the read-from-handle and write them to
6312ac6810fSdjmwrite-to-handle starting from write-to-offset, and then respond with a
6322ac6810fSdjmSSH_FXP_STATUS message.
6332ac6810fSdjm
6342ac6810fSdjmIt's equivalent to issuing a series of SSH_FXP_READ requests on
6352ac6810fSdjmread-from-handle and a series of requests of SSH_FXP_WRITE on
6362ac6810fSdjmwrite-to-handle.
6372ac6810fSdjm
6382ac6810fSdjmIf read-from-handle and write-to-handle are the same, the server will
6392ac6810fSdjmfail the request and respond with a SSH_FX_INVALID_PARAMETER message.
6402ac6810fSdjm
6412ac6810fSdjmIf read-data-length is 0, then the server will read data from the
6422ac6810fSdjmread-from-handle until EOF is reached.
6432ac6810fSdjm
6442ac6810fSdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
6452ac6810fSdjm"1".
6462ac6810fSdjm
6472ac6810fSdjmThis request is identical to the "copy-data" request documented in:
6482ac6810fSdjm
6492ac6810fSdjmhttps://tools.ietf.org/html/draft-ietf-secsh-filexfer-extensions-00#section-7
6502ac6810fSdjm
651d71621f6Sdjm4.11. sftp: Extension request "home-directory"
652d71621f6Sdjm
653d71621f6SdjmThis request asks the server to expand the specified user's home directory.
654d71621f6SdjmAn empty username implies the current user.  This can be used by the client
655d71621f6Sdjmto expand ~/ type paths locally.
656d71621f6Sdjm
657d71621f6Sdjm	byte		SSH_FXP_EXTENDED
658d71621f6Sdjm	uint32		id
659d71621f6Sdjm	string		"home-directory"
660d71621f6Sdjm	string		username
661d71621f6Sdjm
662d71621f6SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
663d71621f6Sdjm"1".
664d71621f6Sdjm
665d71621f6SdjmThis provides similar information as the "expand-path@openssh.com" extension.
666d71621f6Sdjm
667d71621f6SdjmThis request is identical to the "home-directory" request documented in:
668d71621f6Sdjm
669d71621f6Sdjmhttps://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-extensions-00#section-5
670d71621f6Sdjm
67178d13d3aSdjm4.12. sftp: Extension request "users-groups-by-id@openssh.com"
67278d13d3aSdjm
67370271b41SdtuckerThis request asks the server to return user and/or group names that
67478d13d3aSdjmcorrespond to one or more IDs (e.g. as returned from a SSH_FXP_STAT
67578d13d3aSdjmrequest). This may be used by the client to provide usernames in
67678d13d3aSdjmdirectory listings.
67778d13d3aSdjm
67878d13d3aSdjm	byte		SSH_FXP_EXTENDED
67978d13d3aSdjm	uint32		id
68078d13d3aSdjm	string		"users-groups-by-id@openssh.com"
68178d13d3aSdjm	string		uids
68278d13d3aSdjm	string		gids
68378d13d3aSdjm
68478d13d3aSdjmWhere "uids" and "gids" consists of one or more integer user or group
68578d13d3aSdjmidentifiers:
68678d13d3aSdjm
68778d13d3aSdjm	uint32		id-0
68878d13d3aSdjm	...
68978d13d3aSdjm
69078d13d3aSdjmThe server will reply with a SSH_FXP_EXTENDED_REPLY:
69178d13d3aSdjm
69278d13d3aSdjm	byte		SSH_FXP_EXTENDED_REPLY
69378d13d3aSdjm	string		usernames
69478d13d3aSdjm	string		groupnames
69578d13d3aSdjm
69678d13d3aSdjmWhere "username" and "groupnames" consists of names in identical request
69778d13d3aSdjmorder to "uids" and "gids" respectively:
69878d13d3aSdjm
69978d13d3aSdjm	string		name-0
70078d13d3aSdjm	...
70178d13d3aSdjm
70278d13d3aSdjmIf a name cannot be identified for a given user or group ID, an empty
70378d13d3aSdjmstring will be returned in its place.
70478d13d3aSdjm
70578d13d3aSdjmIt is acceptable for either "uids" or "gids" to be an empty set, in
70678d13d3aSdjmwhich case the respective "usernames" or "groupnames" list will also
70778d13d3aSdjmbe empty.
70878d13d3aSdjm
70978d13d3aSdjmThis extension is advertised in the SSH_FXP_VERSION hello with version
71078d13d3aSdjm"1".
71178d13d3aSdjm
712caafdf97Sdjm5. Miscellaneous changes
7137cf46ae9Sdjm
714caafdf97Sdjm5.1 Public key format
7157cf46ae9Sdjm
7167cf46ae9SdjmOpenSSH public keys, as generated by ssh-keygen(1) and appearing in
7177cf46ae9Sdjmauthorized_keys files, are formatted as a single line of text consisting
7187cf46ae9Sdjmof the public key algorithm name followed by a base64-encoded key blob.
71962766785SdjmThe public key blob (before base64 encoding) is the same format used for
72062766785Sdjmthe encoding of public keys sent on the wire: as described in RFC4253
72162766785Sdjmsection 6.6 for RSA and DSA keys, RFC5656 section 3.1 for ECDSA keys
72262766785Sdjmand the "New public key formats" section of PROTOCOL.certkeys for the
72362766785SdjmOpenSSH certificate formats.
7247cf46ae9Sdjm
725caafdf97Sdjm5.2 Private key format
7267cf46ae9Sdjm
7277cf46ae9SdjmOpenSSH private keys, as generated by ssh-keygen(1) use the format
7287cf46ae9Sdjmdescribed in PROTOCOL.key by default. As a legacy option, PEM format
7297cf46ae9Sdjm(RFC7468) private keys are also supported for RSA, DSA and ECDSA keys
7307cf46ae9Sdjmand were the default format before OpenSSH 7.8.
7317cf46ae9Sdjm
732caafdf97Sdjm5.3 KRL format
7337cf46ae9Sdjm
7347cf46ae9SdjmOpenSSH supports a compact format for Key Revocation Lists (KRLs). This
7357cf46ae9Sdjmformat is described in the PROTOCOL.krl file.
7367cf46ae9Sdjm
737caafdf97Sdjm5.4 Connection multiplexing
7387cf46ae9Sdjm
7397cf46ae9SdjmOpenSSH's connection multiplexing uses messages as described in
7407cf46ae9SdjmPROTOCOL.mux over a Unix domain socket for communications between a
7417cf46ae9Sdjmmaster instance and later clients.
7427cf46ae9Sdjm
743caafdf97Sdjm5.5. Agent protocol extensions
744caafdf97Sdjm
745caafdf97SdjmOpenSSH extends the usual agent protocol. These changes are documented
746caafdf97Sdjmin the PROTOCOL.agent file.
747caafdf97Sdjm
748*56f6b460Sdjm$OpenBSD: PROTOCOL,v 1.49 2023/08/28 03:28:43 djm Exp $
749