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 10756f6b460Sdjm1.9 transport: ping facility 10856f6b460Sdjm 10956f6b460SdjmOpenSSH implements a transport level ping message SSH2_MSG_PING 11056f6b460Sdjmand a corresponding SSH2_MSG_PONG reply. 11156f6b460Sdjm 11256f6b460Sdjm#define SSH2_MSG_PING 192 11356f6b460Sdjm#define SSH2_MSG_PONG 193 11456f6b460Sdjm 11556f6b460SdjmThe ping message is simply: 11656f6b460Sdjm 11756f6b460Sdjm byte SSH_MSG_PING 11856f6b460Sdjm string data 11956f6b460Sdjm 12056f6b460SdjmThe reply copies the data (which may be the empty string) from the 12156f6b460Sdjmping: 12256f6b460Sdjm 12356f6b460Sdjm byte SSH_MSG_PONG 12456f6b460Sdjm string data 12556f6b460Sdjm 12656f6b460SdjmReplies are sent in order. They are sent immediately except when rekeying 12756f6b460Sdjmis in progress, in which case they are queued until rekeying completes. 12856f6b460Sdjm 12956f6b460SdjmThe server advertises support for these messages using the 13056f6b460SdjmSSH2_MSG_EXT_INFO mechanism (RFC8308), with the following message: 13156f6b460Sdjm 13256f6b460Sdjm string "ping@openssh.com" 13356f6b460Sdjm string "0" (version) 13456f6b460Sdjm 13556f6b460SdjmThe ping/reply message is implemented at the transport layer rather 13656f6b460Sdjmthan as a named global or channel request to allow pings with very 13756f6b460Sdjmshort packet lengths, which would not be possible with other 13856f6b460Sdjmapproaches. 13956f6b460Sdjm 1401ad9269cSdjm1.10 transport: strict key exchange extension 141622b8b35Sdjm 142622b8b35SdjmOpenSSH supports a number of transport-layer hardening measures under 143622b8b35Sdjma "strict KEX" feature. This feature is signalled similarly to the 144622b8b35SdjmRFC8308 ext-info feature: by including a additional algorithm in the 1450a3ea9a3Sjsginitial SSH2_MSG_KEXINIT kex_algorithms field. The client may append 146622b8b35Sdjm"kex-strict-c-v00@openssh.com" to its kex_algorithms and the server 147622b8b35Sdjmmay append "kex-strict-s-v00@openssh.com". These pseudo-algorithms 148622b8b35Sdjmare only valid in the initial SSH2_MSG_KEXINIT and MUST be ignored 149622b8b35Sdjmif they are present in subsequent SSH2_MSG_KEXINIT packets. 150622b8b35Sdjm 151622b8b35SdjmWhen an endpoint that supports this extension observes this algorithm 152622b8b35Sdjmname in a peer's KEXINIT packet, it MUST make the following changes to 1530a3ea9a3Sjsgthe protocol: 154622b8b35Sdjm 15580afb6f5Sdjma) During initial KEX, terminate the connection if out-of-sequence 15680afb6f5Sdjm packet or any message that is not strictly required by KEX is 15780afb6f5Sdjm received. This includes terminating the connection if the first 15880afb6f5Sdjm packet received is not SSH2_MSG_KEXINIT. Unexpected packets for 15980afb6f5Sdjm the purpose of strict KEX include messages that are otherwise 16080afb6f5Sdjm valid at any time during the connection such as SSH2_MSG_DEBUG, 16180afb6f5Sdjm SSH2_MSG_IGNORE or SSH2_MSG_UNIMPLEMENTED. 162622b8b35Sdjmb) After sending or receiving a SSH2_MSG_NEWKEYS message, reset the 163622b8b35Sdjm packet sequence number to zero. This behaviour persists for the 164622b8b35Sdjm duration of the connection (i.e. not just the first 165622b8b35Sdjm SSH2_MSG_NEWKEYS). 166622b8b35Sdjm 1671ad9269cSdjm1.11 transport: SSH2_MSG_EXT_INFO during user authentication 16831381235Sdjm 16931381235SdjmThis protocol extension allows the SSH2_MSG_EXT_INFO to be sent 17031381235Sdjmduring user authentication. RFC8308 does allow a second 17131381235SdjmSSH2_MSG_EXT_INFO notification, but it may only be sent at the end 17231381235Sdjmof user authentication and this is too late to signal per-user 17331381235Sdjmserver signature algorithms. 17431381235Sdjm 17531381235SdjmSupport for receiving the SSH2_MSG_EXT_INFO message during user 17631381235Sdjmauthentication is signalled by the client including a 17731381235Sdjm"ext-info-in-auth@openssh.com" key via its initial SSH2_MSG_EXT_INFO 17831381235Sdjmset after the SSH2_MSG_NEWKEYS message. 17931381235Sdjm 18031381235SdjmA server that supports this extension MAY send a second 18131381235SdjmSSH2_MSG_EXT_INFO message any time after the client's first 18231381235SdjmSSH2_MSG_USERAUTH_REQUEST, regardless of whether it succeed or fails. 18331381235SdjmThe client SHOULD be prepared to update the server-sig-algs that 18431381235Sdjmit received during an earlier SSH2_MSG_EXT_INFO with the later one. 18531381235Sdjm 186f6c05033Sdjm2. Connection protocol changes 187f6c05033Sdjm 188f6c05033Sdjm2.1. connection: Channel write close extension "eow@openssh.com" 189422225e8Sdjm 190422225e8SdjmThe SSH connection protocol (rfc4254) provides the SSH_MSG_CHANNEL_EOF 191422225e8Sdjmmessage to allow an endpoint to signal its peer that it will send no 192422225e8Sdjmmore data over a channel. Unfortunately, there is no symmetric way for 193422225e8Sdjman endpoint to request that its peer should cease sending data to it 194422225e8Sdjmwhile still keeping the channel open for the endpoint to send data to 195422225e8Sdjmthe peer. 196422225e8Sdjm 19738d4658eSdjmThis is desirable, since it saves the transmission of data that would 198422225e8Sdjmotherwise need to be discarded and it allows an endpoint to signal local 199422225e8Sdjmprocesses of the condition, e.g. by closing the corresponding file 200422225e8Sdjmdescriptor. 201422225e8Sdjm 202422225e8SdjmOpenSSH implements a channel extension message to perform this 2037153c228Sdjmsignalling: "eow@openssh.com" (End Of Write). This message is sent by 2047153c228Sdjman endpoint when the local output of a session channel is closed or 2057153c228Sdjmexperiences a write error. The message is formatted as follows: 206422225e8Sdjm 207422225e8Sdjm byte SSH_MSG_CHANNEL_REQUEST 208422225e8Sdjm uint32 recipient channel 209422225e8Sdjm string "eow@openssh.com" 210422225e8Sdjm boolean FALSE 211422225e8Sdjm 212422225e8SdjmOn receiving this message, the peer SHOULD cease sending data of 213422225e8Sdjmthe channel and MAY signal the process from which the channel data 214422225e8Sdjmoriginates (e.g. by closing its read file descriptor). 215422225e8Sdjm 216422225e8SdjmAs with the symmetric SSH_MSG_CHANNEL_EOF message, the channel does 217422225e8Sdjmremain open after a "eow@openssh.com" has been sent and more data may 218422225e8Sdjmstill be sent in the other direction. This message does not consume 219422225e8Sdjmwindow space and may be sent even if no window space is available. 220422225e8Sdjm 221e187e146SdjmNB. due to certain broken SSH implementations aborting upon receipt 222e187e146Sdjmof this message (in contravention of RFC4254 section 5.4), this 223e187e146Sdjmmessage is only sent to OpenSSH peers (identified by banner). 2245bde2954SdjmOther SSH implementations may be listed to receive this message 225e187e146Sdjmupon request. 226e187e146Sdjm 227f6c05033Sdjm2.2. connection: disallow additional sessions extension 22882046f86Sdjm "no-more-sessions@openssh.com" 22982046f86Sdjm 23082046f86SdjmMost SSH connections will only ever request a single session, but a 23182046f86Sdjmattacker may abuse a running ssh client to surreptitiously open 23282046f86Sdjmadditional sessions under their control. OpenSSH provides a global 23382046f86Sdjmrequest "no-more-sessions@openssh.com" to mitigate this attack. 23482046f86Sdjm 23582046f86SdjmWhen an OpenSSH client expects that it will never open another session 23682046f86Sdjm(i.e. it has been started with connection multiplexing disabled), it 23782046f86Sdjmwill send the following global request: 23882046f86Sdjm 23982046f86Sdjm byte SSH_MSG_GLOBAL_REQUEST 24082046f86Sdjm string "no-more-sessions@openssh.com" 24182046f86Sdjm char want-reply 24282046f86Sdjm 24382046f86SdjmOn receipt of such a message, an OpenSSH server will refuse to open 24482046f86Sdjmfuture channels of type "session" and instead immediately abort the 24582046f86Sdjmconnection. 24682046f86Sdjm 24782046f86SdjmNote that this is not a general defence against compromised clients 24882046f86Sdjm(that is impossible), but it thwarts a simple attack. 24982046f86Sdjm 250e187e146SdjmNB. due to certain broken SSH implementations aborting upon receipt 251e187e146Sdjmof this message, the no-more-sessions request is only sent to OpenSSH 252e187e146Sdjmservers (identified by banner). Other SSH implementations may be 2535bde2954Sdjmlisted to receive this message upon request. 254e187e146Sdjm 255f6c05033Sdjm2.3. connection: Tunnel forward extension "tun@openssh.com" 2560afb9521Sdjm 2576c9c8648SdjmOpenSSH supports layer 2 and layer 3 tunnelling via the "tun@openssh.com" 2580afb9521Sdjmchannel type. This channel type supports forwarding of network packets 2596c9c8648Sdjmwith datagram boundaries intact between endpoints equipped with 2600afb9521Sdjminterfaces like the BSD tun(4) device. Tunnel forwarding channels are 2610afb9521Sdjmrequested by the client with the following packet: 2620afb9521Sdjm 2630afb9521Sdjm byte SSH_MSG_CHANNEL_OPEN 2640afb9521Sdjm string "tun@openssh.com" 2650afb9521Sdjm uint32 sender channel 2660afb9521Sdjm uint32 initial window size 2670afb9521Sdjm uint32 maximum packet size 2680afb9521Sdjm uint32 tunnel mode 2690afb9521Sdjm uint32 remote unit number 2700afb9521Sdjm 2710afb9521SdjmThe "tunnel mode" parameter specifies whether the tunnel should forward 2720afb9521Sdjmlayer 2 frames or layer 3 packets. It may take one of the following values: 2730afb9521Sdjm 2740afb9521Sdjm SSH_TUNMODE_POINTOPOINT 1 /* layer 3 packets */ 2750afb9521Sdjm SSH_TUNMODE_ETHERNET 2 /* layer 2 frames */ 2760afb9521Sdjm 2770afb9521SdjmThe "tunnel unit number" specifies the remote interface number, or may 27838ea1073Sdtuckerbe 0x7fffffff to allow the server to automatically choose an interface. A 279c880fb56Sdjmserver that is not willing to open a client-specified unit should refuse 280c880fb56Sdjmthe request with a SSH_MSG_CHANNEL_OPEN_FAILURE error. On successful 281c880fb56Sdjmopen, the server should reply with SSH_MSG_CHANNEL_OPEN_SUCCESS. 2820afb9521Sdjm 2830afb9521SdjmOnce established the client and server may exchange packet or frames 2840afb9521Sdjmover the tunnel channel by encapsulating them in SSH protocol strings 2850afb9521Sdjmand sending them as channel data. This ensures that packet boundaries 2860afb9521Sdjmare kept intact. Specifically, packets are transmitted using normal 2870afb9521SdjmSSH_MSG_CHANNEL_DATA packets: 2880afb9521Sdjm 2890afb9521Sdjm byte SSH_MSG_CHANNEL_DATA 2900afb9521Sdjm uint32 recipient channel 2910afb9521Sdjm string data 2920afb9521Sdjm 2930afb9521SdjmThe contents of the "data" field for layer 3 packets is: 2940afb9521Sdjm 2950afb9521Sdjm uint32 packet length 2960afb9521Sdjm uint32 address family 2970afb9521Sdjm byte[packet length - 4] packet data 2980afb9521Sdjm 2990afb9521SdjmThe "address family" field identifies the type of packet in the message. 3000afb9521SdjmIt may be one of: 3010afb9521Sdjm 3020afb9521Sdjm SSH_TUN_AF_INET 2 /* IPv4 */ 3030afb9521Sdjm SSH_TUN_AF_INET6 24 /* IPv6 */ 3040afb9521Sdjm 3050afb9521SdjmThe "packet data" field consists of the IPv4/IPv6 datagram itself 3060afb9521Sdjmwithout any link layer header. 3070afb9521Sdjm 308c880fb56SdjmThe contents of the "data" field for layer 2 packets is: 3090afb9521Sdjm 3100afb9521Sdjm uint32 packet length 3110afb9521Sdjm byte[packet length] frame 3120afb9521Sdjm 3136c9c8648SdjmThe "frame" field contains an IEEE 802.3 Ethernet frame, including 3140afb9521Sdjmheader. 3150afb9521Sdjm 316a0215499Smillert2.4. connection: Unix domain socket forwarding 317a0215499Smillert 318a0215499SmillertOpenSSH supports local and remote Unix domain socket forwarding 319a0215499Smillertusing the "streamlocal" extension. Forwarding is initiated as per 320a0215499SmillertTCP sockets but with a single path instead of a host and port. 321a0215499Smillert 322a0215499SmillertSimilar to direct-tcpip, direct-streamlocal is sent by the client 323a0215499Smillertto request that the server make a connection to a Unix domain socket. 324a0215499Smillert 325a0215499Smillert byte SSH_MSG_CHANNEL_OPEN 326a0215499Smillert string "direct-streamlocal@openssh.com" 327a0215499Smillert uint32 sender channel 328a0215499Smillert uint32 initial window size 329a0215499Smillert uint32 maximum packet size 330a0215499Smillert string socket path 3313e584310Sdjm string reserved 3323e584310Sdjm uint32 reserved 333a0215499Smillert 334a0215499SmillertSimilar to forwarded-tcpip, forwarded-streamlocal is sent by the 335a0215499Smillertserver when the client has previously send the server a streamlocal-forward 336a0215499SmillertGLOBAL_REQUEST. 337a0215499Smillert 338a0215499Smillert byte SSH_MSG_CHANNEL_OPEN 339a0215499Smillert string "forwarded-streamlocal@openssh.com" 340a0215499Smillert uint32 sender channel 341a0215499Smillert uint32 initial window size 342a0215499Smillert uint32 maximum packet size 343a0215499Smillert string socket path 344a0215499Smillert string reserved for future use 345a0215499Smillert 346a0215499SmillertThe reserved field is not currently defined and is ignored on the 347a0215499Smillertremote end. It is intended to be used in the future to pass 348a0215499Smillertinformation about the socket file, such as ownership and mode. 349a0215499SmillertThe client currently sends the empty string for this field. 350a0215499Smillert 351a0215499SmillertSimilar to tcpip-forward, streamlocal-forward is sent by the client 352a0215499Smillertto request remote forwarding of a Unix domain socket. 353a0215499Smillert 354a0215499Smillert byte SSH2_MSG_GLOBAL_REQUEST 355a0215499Smillert string "streamlocal-forward@openssh.com" 356a0215499Smillert boolean TRUE 357a0215499Smillert string socket path 358a0215499Smillert 359a0215499SmillertSimilar to cancel-tcpip-forward, cancel-streamlocal-forward is sent 360a0215499Smillertby the client cancel the forwarding of a Unix domain socket. 361a0215499Smillert 362a0215499Smillert byte SSH2_MSG_GLOBAL_REQUEST 363a0215499Smillert string "cancel-streamlocal-forward@openssh.com" 364a0215499Smillert boolean FALSE 365a0215499Smillert string socket path 366a0215499Smillert 3673782b423Sdjm2.5. connection: hostkey update and rotation "hostkeys-00@openssh.com" 3683782b423Sdjmand "hostkeys-prove-00@openssh.com" 36906c9be66Sdjm 37006c9be66SdjmOpenSSH supports a protocol extension allowing a server to inform 37106c9be66Sdjma client of all its protocol v.2 host keys after user-authentication 37206c9be66Sdjmhas completed. 37306c9be66Sdjm 37406c9be66Sdjm byte SSH_MSG_GLOBAL_REQUEST 3753782b423Sdjm string "hostkeys-00@openssh.com" 3762514f071Sdjm char 0 /* want-reply */ 37706c9be66Sdjm string[] hostkeys 37806c9be66Sdjm 37983fcfd69SdjmUpon receiving this message, a client should check which of the 38061185547Sdjmsupplied host keys are present in known_hosts. 38161185547Sdjm 38261185547SdjmNote that the server may send key types that the client does not 38338ea1073Sdtuckersupport. The client should disregard such keys if they are received. 38461185547Sdjm 38561185547SdjmIf the client identifies any keys that are not present for the host, 38661185547Sdjmit should send a "hostkeys-prove@openssh.com" message to request the 38761185547Sdjmserver prove ownership of the private half of the key. 38806c9be66Sdjm 38983fcfd69Sdjm byte SSH_MSG_GLOBAL_REQUEST 3903782b423Sdjm string "hostkeys-prove-00@openssh.com" 39183fcfd69Sdjm char 1 /* want-reply */ 39283fcfd69Sdjm string[] hostkeys 39383fcfd69Sdjm 39483fcfd69SdjmWhen a server receives this message, it should generate a signature 39583fcfd69Sdjmusing each requested key over the following: 39683fcfd69Sdjm 3973782b423Sdjm string "hostkeys-prove-00@openssh.com" 39883fcfd69Sdjm string session identifier 39983fcfd69Sdjm string hostkey 40083fcfd69Sdjm 40183fcfd69SdjmThese signatures should be included in the reply, in the order matching 40283fcfd69Sdjmthe hostkeys in the request: 40383fcfd69Sdjm 40483fcfd69Sdjm byte SSH_MSG_REQUEST_SUCCESS 40583fcfd69Sdjm string[] signatures 40683fcfd69Sdjm 40783fcfd69SdjmWhen the client receives this reply (and not a failure), it should 40883fcfd69Sdjmvalidate the signatures and may update its known_hosts file, adding keys 40983fcfd69Sdjmthat it has not seen before and deleting keys for the server host that 41083fcfd69Sdjmare no longer offered. 41183fcfd69Sdjm 41283fcfd69SdjmThese extensions let a client learn key types that it had not previously 41383fcfd69Sdjmencountered, thereby allowing it to potentially upgrade from weaker 41483fcfd69Sdjmkey algorithms to better ones. It also supports graceful key rotation: 41583fcfd69Sdjma server may offer multiple keys of the same type for a period (to 41683fcfd69Sdjmgive clients an opportunity to learn them using this extension) before 41783fcfd69Sdjmremoving the deprecated key from those offered. 41806c9be66Sdjm 419a098558bSdjm2.6. connection: SIGINFO support for "signal" channel request 420a098558bSdjm 421a098558bSdjmThe SSH channels protocol (RFC4254 section 6.9) supports sending a 422a098558bSdjmsignal to a session attached to a channel. OpenSSH supports one 423a098558bSdjmextension signal "INFO@openssh.com" that allows sending SIGINFO on 424a098558bSdjmBSD-derived systems. 425a098558bSdjm 426caafdf97Sdjm3. Authentication protocol changes 427f6c05033Sdjm 428caafdf97Sdjm3.1. Host-bound public key authentication 429caafdf97Sdjm 430caafdf97SdjmThis is trivial change to the traditional "publickey" authentication 431caafdf97Sdjmmethod. The authentication request is identical to the original method 432caafdf97Sdjmbut for the name and one additional field: 433caafdf97Sdjm 434caafdf97Sdjm byte SSH2_MSG_USERAUTH_REQUEST 435caafdf97Sdjm string username 436caafdf97Sdjm string "ssh-connection" 437caafdf97Sdjm string "publickey-hostbound-v00@openssh.com" 438caafdf97Sdjm bool has_signature 439caafdf97Sdjm string pkalg 440caafdf97Sdjm string public key 441caafdf97Sdjm string server host key 442caafdf97Sdjm 443caafdf97SdjmBecause the entire SSH2_MSG_USERAUTH_REQUEST message is included in 444caafdf97Sdjmthe signed data, this ensures that a binding between the destination 445caafdf97Sdjmuser, the server identity and the session identifier is visible to the 446caafdf97Sdjmsigner. OpenSSH uses this binding via signed data to implement per-key 447caafdf97Sdjmrestrictions in ssh-agent. 448caafdf97Sdjm 449caafdf97SdjmA server may advertise this method using the SSH2_MSG_EXT_INFO 450caafdf97Sdjmmechanism (RFC8308), with the following message: 451caafdf97Sdjm 452caafdf97Sdjm string "publickey-hostbound@openssh.com" 453caafdf97Sdjm string "0" (version) 454caafdf97Sdjm 455caafdf97SdjmClients should prefer host-bound authentication when advertised by 456caafdf97Sdjmserver. 457caafdf97Sdjm 458caafdf97Sdjm4. SFTP protocol changes 459caafdf97Sdjm 460caafdf97Sdjm4.1. sftp: Reversal of arguments to SSH_FXP_SYMLINK 461422225e8Sdjm 462422225e8SdjmWhen OpenSSH's sftp-server was implemented, the order of the arguments 4636c9c8648Sdjmto the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately, 464422225e8Sdjmthe reversal was not noticed until the server was widely deployed. Since 465422225e8Sdjmfixing this to follow the specification would cause incompatibility, the 466422225e8Sdjmcurrent order was retained. For correct operation, clients should send 467422225e8SdjmSSH_FXP_SYMLINK as follows: 468422225e8Sdjm 469422225e8Sdjm uint32 id 470422225e8Sdjm string targetpath 471422225e8Sdjm string linkpath 472422225e8Sdjm 473caafdf97Sdjm4.2. sftp: Server extension announcement in SSH_FXP_VERSION 474422225e8Sdjm 475422225e8SdjmOpenSSH's sftp-server lists the extensions it supports using the 476422225e8Sdjmstandard extension announcement mechanism in the SSH_FXP_VERSION server 477422225e8Sdjmhello packet: 478422225e8Sdjm 479422225e8Sdjm uint32 3 /* protocol version */ 480422225e8Sdjm string ext1-name 481422225e8Sdjm string ext1-version 482422225e8Sdjm string ext2-name 483422225e8Sdjm string ext2-version 484422225e8Sdjm ... 485422225e8Sdjm string extN-name 486422225e8Sdjm string extN-version 487422225e8Sdjm 488422225e8SdjmEach extension reports its integer version number as an ASCII encoded 489422225e8Sdjmstring, e.g. "1". The version will be incremented if the extension is 490422225e8Sdjmever changed in an incompatible way. The server MAY advertise the same 491422225e8Sdjmextension with multiple versions (though this is unlikely). Clients MUST 4926c9c8648Sdjmcheck the version number before attempting to use the extension. 493422225e8Sdjm 494caafdf97Sdjm4.3. sftp: Extension request "posix-rename@openssh.com" 495422225e8Sdjm 496422225e8SdjmThis operation provides a rename operation with POSIX semantics, which 497422225e8Sdjmare different to those provided by the standard SSH_FXP_RENAME in 498422225e8Sdjmdraft-ietf-secsh-filexfer-02.txt. This request is implemented as a 499422225e8SdjmSSH_FXP_EXTENDED request with the following format: 500422225e8Sdjm 501422225e8Sdjm uint32 id 502422225e8Sdjm string "posix-rename@openssh.com" 503422225e8Sdjm string oldpath 504422225e8Sdjm string newpath 505422225e8Sdjm 506422225e8SdjmOn receiving this request the server will perform the POSIX operation 507422225e8Sdjmrename(oldpath, newpath) and will respond with a SSH_FXP_STATUS message. 508422225e8SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 509422225e8Sdjm"1". 510422225e8Sdjm 511caafdf97Sdjm4.4. sftp: Extension requests "statvfs@openssh.com" and 512422225e8Sdjm "fstatvfs@openssh.com" 513422225e8Sdjm 514422225e8SdjmThese requests correspond to the statvfs and fstatvfs POSIX system 515422225e8Sdjminterfaces. The "statvfs@openssh.com" request operates on an explicit 516422225e8Sdjmpathname, and is formatted as follows: 517422225e8Sdjm 518422225e8Sdjm uint32 id 519422225e8Sdjm string "statvfs@openssh.com" 520422225e8Sdjm string path 521422225e8Sdjm 522422225e8SdjmThe "fstatvfs@openssh.com" operates on an open file handle: 523422225e8Sdjm 524422225e8Sdjm uint32 id 52538d4658eSdjm string "fstatvfs@openssh.com" 526422225e8Sdjm string handle 527422225e8Sdjm 528422225e8SdjmThese requests return a SSH_FXP_STATUS reply on failure. On success they 529422225e8Sdjmreturn the following SSH_FXP_EXTENDED_REPLY reply: 530422225e8Sdjm 531422225e8Sdjm uint32 id 532f00164cfSdtucker uint64 f_bsize /* file system block size */ 533f00164cfSdtucker uint64 f_frsize /* fundamental fs block size */ 534422225e8Sdjm uint64 f_blocks /* number of blocks (unit f_frsize) */ 535422225e8Sdjm uint64 f_bfree /* free blocks in file system */ 536422225e8Sdjm uint64 f_bavail /* free blocks for non-root */ 537422225e8Sdjm uint64 f_files /* total file inodes */ 538422225e8Sdjm uint64 f_ffree /* free file inodes */ 539422225e8Sdjm uint64 f_favail /* free file inodes for to non-root */ 54033745cbfSdjm uint64 f_fsid /* file system id */ 541f00164cfSdtucker uint64 f_flag /* bit mask of f_flag values */ 542f00164cfSdtucker uint64 f_namemax /* maximum filename length */ 543422225e8Sdjm 544422225e8SdjmThe values of the f_flag bitmask are as follows: 545422225e8Sdjm 546422225e8Sdjm #define SSH_FXE_STATVFS_ST_RDONLY 0x1 /* read-only */ 547422225e8Sdjm #define SSH_FXE_STATVFS_ST_NOSUID 0x2 /* no setuid */ 548422225e8Sdjm 549fae5684aSdjmBoth the "statvfs@openssh.com" and "fstatvfs@openssh.com" extensions are 550fae5684aSdjmadvertised in the SSH_FXP_VERSION hello with version "2". 55133745cbfSdjm 552caafdf97Sdjm4.5. sftp: Extension request "hardlink@openssh.com" 5539c120764Sdjm 5549c120764SdjmThis request is for creating a hard link to a regular file. This 5559c120764Sdjmrequest is implemented as a SSH_FXP_EXTENDED request with the 5569c120764Sdjmfollowing format: 5579c120764Sdjm 5589c120764Sdjm uint32 id 5599c120764Sdjm string "hardlink@openssh.com" 5609c120764Sdjm string oldpath 5619c120764Sdjm string newpath 5629c120764Sdjm 5639c120764SdjmOn receiving this request the server will perform the operation 5649c120764Sdjmlink(oldpath, newpath) and will respond with a SSH_FXP_STATUS message. 5659c120764SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 5669c120764Sdjm"1". 5679c120764Sdjm 568caafdf97Sdjm4.6. sftp: Extension request "fsync@openssh.com" 56994e35841Sdjm 57094e35841SdjmThis request asks the server to call fsync(2) on an open file handle. 57194e35841Sdjm 57294e35841Sdjm uint32 id 57394e35841Sdjm string "fsync@openssh.com" 57494e35841Sdjm string handle 57594e35841Sdjm 5762ac6810fSdjmOn receiving this request, a server will call fsync(handle_fd) and will 57794e35841Sdjmrespond with a SSH_FXP_STATUS message. 57894e35841Sdjm 57994e35841SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 58094e35841Sdjm"1". 58194e35841Sdjm 582caafdf97Sdjm4.7. sftp: Extension request "lsetstat@openssh.com" 5834dc35148Sdjm 5844dc35148SdjmThis request is like the "setstat" command, but sets file attributes on 5854dc35148Sdjmsymlinks. It is implemented as a SSH_FXP_EXTENDED request with the 5864dc35148Sdjmfollowing format: 5874dc35148Sdjm 5884dc35148Sdjm uint32 id 5894dc35148Sdjm string "lsetstat@openssh.com" 5904dc35148Sdjm string path 5914dc35148Sdjm ATTRS attrs 5924dc35148Sdjm 5934dc35148SdjmSee the "setstat" command for more details. 5944dc35148Sdjm 5954dc35148SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 5964dc35148Sdjm"1". 5974dc35148Sdjm 598caafdf97Sdjm4.8. sftp: Extension request "limits@openssh.com" 599029b49a0Sdjm 600029b49a0SdjmThis request is used to determine various limits the server might impose. 601029b49a0SdjmClients should not attempt to exceed these limits as the server might sever 602029b49a0Sdjmthe connection immediately. 603029b49a0Sdjm 604029b49a0Sdjm uint32 id 605029b49a0Sdjm string "limits@openssh.com" 606029b49a0Sdjm 607029b49a0SdjmThe server will respond with a SSH_FXP_EXTENDED_REPLY reply: 608029b49a0Sdjm 609029b49a0Sdjm uint32 id 610029b49a0Sdjm uint64 max-packet-length 611029b49a0Sdjm uint64 max-read-length 612029b49a0Sdjm uint64 max-write-length 613029b49a0Sdjm uint64 max-open-handles 614029b49a0Sdjm 615029b49a0SdjmThe 'max-packet-length' applies to the total number of bytes in a 616029b49a0Sdjmsingle SFTP packet. Servers SHOULD set this at least to 34000. 617029b49a0Sdjm 618029b49a0SdjmThe 'max-read-length' is the largest length in a SSH_FXP_READ packet. 619029b49a0SdjmEven if the client requests a larger size, servers will usually respond 620029b49a0Sdjmwith a shorter SSH_FXP_DATA packet. Servers SHOULD set this at least to 621029b49a0Sdjm32768. 622029b49a0Sdjm 623029b49a0SdjmThe 'max-write-length' is the largest length in a SSH_FXP_WRITE packet 624029b49a0Sdjmthe server will accept. Servers SHOULD set this at least to 32768. 625029b49a0Sdjm 626029b49a0SdjmThe 'max-open-handles' is the maximum number of active handles that the 627029b49a0Sdjmserver allows (e.g. handles created by SSH_FXP_OPEN and SSH_FXP_OPENDIR 628029b49a0Sdjmpackets). Servers MAY count internal file handles against this limit 629029b49a0Sdjm(e.g. system logging or stdout/stderr), so clients SHOULD NOT expect to 630029b49a0Sdjmopen this many handles in practice. 631029b49a0Sdjm 632029b49a0SdjmIf the server doesn't enforce a specific limit, then the field may be 633029b49a0Sdjmset to 0. This implies the server relies on the OS to enforce limits 634029b49a0Sdjm(e.g. available memory or file handles), and such limits might be 635029b49a0Sdjmdynamic. The client SHOULD take care to not try to exceed reasonable 636029b49a0Sdjmlimits. 637029b49a0Sdjm 638029b49a0SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 639029b49a0Sdjm"1". 640029b49a0Sdjm 641caafdf97Sdjm4.9. sftp: Extension request "expand-path@openssh.com" 642e4383b47Sdjm 643e4383b47SdjmThis request supports canonicalisation of relative paths and 644e4383b47Sdjmthose that need tilde-expansion, i.e. "~", "~/..." and "~user/..." 645e4383b47SdjmThese paths are expanded using shell-like rules and the resultant 646e4383b47Sdjmpath is canonicalised similarly to SSH2_FXP_REALPATH. 647e4383b47Sdjm 648e4383b47SdjmIt is implemented as a SSH_FXP_EXTENDED request with the following 649e4383b47Sdjmformat: 650e4383b47Sdjm 651e4383b47Sdjm uint32 id 652e4383b47Sdjm string "expand-path@openssh.com" 653e4383b47Sdjm string path 654e4383b47Sdjm 655e4383b47SdjmIts reply is the same format as that of SSH2_FXP_REALPATH. 656e4383b47Sdjm 657e4383b47SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 658e4383b47Sdjm"1". 659e4383b47Sdjm 6602ac6810fSdjm4.10. sftp: Extension request "copy-data" 6612ac6810fSdjm 6622ac6810fSdjmThis request asks the server to copy data from one open file handle and 6632ac6810fSdjmwrite it to a different open file handle. This avoids needing to transfer 6642ac6810fSdjmthe data across the network twice (a download followed by an upload). 6652ac6810fSdjm 6662ac6810fSdjm byte SSH_FXP_EXTENDED 6672ac6810fSdjm uint32 id 6682ac6810fSdjm string "copy-data" 6692ac6810fSdjm string read-from-handle 6702ac6810fSdjm uint64 read-from-offset 6712ac6810fSdjm uint64 read-data-length 6722ac6810fSdjm string write-to-handle 6732ac6810fSdjm uint64 write-to-offset 6742ac6810fSdjm 6752ac6810fSdjmThe server will copy read-data-length bytes starting from 6762ac6810fSdjmread-from-offset from the read-from-handle and write them to 6772ac6810fSdjmwrite-to-handle starting from write-to-offset, and then respond with a 6782ac6810fSdjmSSH_FXP_STATUS message. 6792ac6810fSdjm 6802ac6810fSdjmIt's equivalent to issuing a series of SSH_FXP_READ requests on 6812ac6810fSdjmread-from-handle and a series of requests of SSH_FXP_WRITE on 6822ac6810fSdjmwrite-to-handle. 6832ac6810fSdjm 6842ac6810fSdjmIf read-from-handle and write-to-handle are the same, the server will 6852ac6810fSdjmfail the request and respond with a SSH_FX_INVALID_PARAMETER message. 6862ac6810fSdjm 6872ac6810fSdjmIf read-data-length is 0, then the server will read data from the 6882ac6810fSdjmread-from-handle until EOF is reached. 6892ac6810fSdjm 6902ac6810fSdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 6912ac6810fSdjm"1". 6922ac6810fSdjm 6932ac6810fSdjmThis request is identical to the "copy-data" request documented in: 6942ac6810fSdjm 6952ac6810fSdjmhttps://tools.ietf.org/html/draft-ietf-secsh-filexfer-extensions-00#section-7 6962ac6810fSdjm 697d71621f6Sdjm4.11. sftp: Extension request "home-directory" 698d71621f6Sdjm 699d71621f6SdjmThis request asks the server to expand the specified user's home directory. 700d71621f6SdjmAn empty username implies the current user. This can be used by the client 701d71621f6Sdjmto expand ~/ type paths locally. 702d71621f6Sdjm 703d71621f6Sdjm byte SSH_FXP_EXTENDED 704d71621f6Sdjm uint32 id 705d71621f6Sdjm string "home-directory" 706d71621f6Sdjm string username 707d71621f6Sdjm 708d71621f6SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 709d71621f6Sdjm"1". 710d71621f6Sdjm 711d71621f6SdjmThis provides similar information as the "expand-path@openssh.com" extension. 712d71621f6Sdjm 713d71621f6SdjmThis request is identical to the "home-directory" request documented in: 714d71621f6Sdjm 715d71621f6Sdjmhttps://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-extensions-00#section-5 716d71621f6Sdjm 71778d13d3aSdjm4.12. sftp: Extension request "users-groups-by-id@openssh.com" 71878d13d3aSdjm 71970271b41SdtuckerThis request asks the server to return user and/or group names that 72078d13d3aSdjmcorrespond to one or more IDs (e.g. as returned from a SSH_FXP_STAT 72178d13d3aSdjmrequest). This may be used by the client to provide usernames in 72278d13d3aSdjmdirectory listings. 72378d13d3aSdjm 72478d13d3aSdjm byte SSH_FXP_EXTENDED 72578d13d3aSdjm uint32 id 72678d13d3aSdjm string "users-groups-by-id@openssh.com" 72778d13d3aSdjm string uids 72878d13d3aSdjm string gids 72978d13d3aSdjm 73078d13d3aSdjmWhere "uids" and "gids" consists of one or more integer user or group 73178d13d3aSdjmidentifiers: 73278d13d3aSdjm 73378d13d3aSdjm uint32 id-0 73478d13d3aSdjm ... 73578d13d3aSdjm 73678d13d3aSdjmThe server will reply with a SSH_FXP_EXTENDED_REPLY: 73778d13d3aSdjm 73878d13d3aSdjm byte SSH_FXP_EXTENDED_REPLY 739*1c497181Sdjm uint32 id 74078d13d3aSdjm string usernames 74178d13d3aSdjm string groupnames 74278d13d3aSdjm 74378d13d3aSdjmWhere "username" and "groupnames" consists of names in identical request 74478d13d3aSdjmorder to "uids" and "gids" respectively: 74578d13d3aSdjm 74678d13d3aSdjm string name-0 74778d13d3aSdjm ... 74878d13d3aSdjm 74978d13d3aSdjmIf a name cannot be identified for a given user or group ID, an empty 75078d13d3aSdjmstring will be returned in its place. 75178d13d3aSdjm 75278d13d3aSdjmIt is acceptable for either "uids" or "gids" to be an empty set, in 75378d13d3aSdjmwhich case the respective "usernames" or "groupnames" list will also 75478d13d3aSdjmbe empty. 75578d13d3aSdjm 75678d13d3aSdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 75778d13d3aSdjm"1". 75878d13d3aSdjm 759caafdf97Sdjm5. Miscellaneous changes 7607cf46ae9Sdjm 761caafdf97Sdjm5.1 Public key format 7627cf46ae9Sdjm 7637cf46ae9SdjmOpenSSH public keys, as generated by ssh-keygen(1) and appearing in 7647cf46ae9Sdjmauthorized_keys files, are formatted as a single line of text consisting 7657cf46ae9Sdjmof the public key algorithm name followed by a base64-encoded key blob. 76662766785SdjmThe public key blob (before base64 encoding) is the same format used for 76762766785Sdjmthe encoding of public keys sent on the wire: as described in RFC4253 76862766785Sdjmsection 6.6 for RSA and DSA keys, RFC5656 section 3.1 for ECDSA keys 76962766785Sdjmand the "New public key formats" section of PROTOCOL.certkeys for the 77062766785SdjmOpenSSH certificate formats. 7717cf46ae9Sdjm 772caafdf97Sdjm5.2 Private key format 7737cf46ae9Sdjm 7747cf46ae9SdjmOpenSSH private keys, as generated by ssh-keygen(1) use the format 7757cf46ae9Sdjmdescribed in PROTOCOL.key by default. As a legacy option, PEM format 7767cf46ae9Sdjm(RFC7468) private keys are also supported for RSA, DSA and ECDSA keys 7777cf46ae9Sdjmand were the default format before OpenSSH 7.8. 7787cf46ae9Sdjm 779caafdf97Sdjm5.3 KRL format 7807cf46ae9Sdjm 7817cf46ae9SdjmOpenSSH supports a compact format for Key Revocation Lists (KRLs). This 7827cf46ae9Sdjmformat is described in the PROTOCOL.krl file. 7837cf46ae9Sdjm 784caafdf97Sdjm5.4 Connection multiplexing 7857cf46ae9Sdjm 7867cf46ae9SdjmOpenSSH's connection multiplexing uses messages as described in 7877cf46ae9SdjmPROTOCOL.mux over a Unix domain socket for communications between a 7887cf46ae9Sdjmmaster instance and later clients. 7897cf46ae9Sdjm 790caafdf97Sdjm5.5. Agent protocol extensions 791caafdf97Sdjm 792caafdf97SdjmOpenSSH extends the usual agent protocol. These changes are documented 793caafdf97Sdjmin the PROTOCOL.agent file. 794caafdf97Sdjm 795*1c497181Sdjm$OpenBSD: PROTOCOL,v 1.55 2024/01/08 05:05:15 djm Exp $ 796