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 36f6c05033Sdjm1.3. transport: New public key algorithms "ssh-rsa-cert-v00@openssh.com", 37f6c05033Sdjm "ssh-dsa-cert-v00@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 43b94e498eSdjmauthentication for users and hostkeys. These methods are documented in 44b94e498eSdjmthe 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 73*4ea77511Sdjm mac = MAC(key, sequence_number || packet_length || encrypted_packet) 74c2ea1f0aSmarkus 75*4ea77511Sdjmwhere "packet_length" is encoded as a uint32 and "encrypted_packet" 76*4ea77511Sdjmcontains: 77c2ea1f0aSmarkus 78c2ea1f0aSmarkus byte padding_length 79c2ea1f0aSmarkus byte[n1] payload; n1 = packet_length - padding_length - 1 80c2ea1f0aSmarkus byte[n2] random padding; n2 = padding_length 81c2ea1f0aSmarkus 82f6c05033Sdjm2. Connection protocol changes 83f6c05033Sdjm 84f6c05033Sdjm2.1. connection: Channel write close extension "eow@openssh.com" 85422225e8Sdjm 86422225e8SdjmThe SSH connection protocol (rfc4254) provides the SSH_MSG_CHANNEL_EOF 87422225e8Sdjmmessage to allow an endpoint to signal its peer that it will send no 88422225e8Sdjmmore data over a channel. Unfortunately, there is no symmetric way for 89422225e8Sdjman endpoint to request that its peer should cease sending data to it 90422225e8Sdjmwhile still keeping the channel open for the endpoint to send data to 91422225e8Sdjmthe peer. 92422225e8Sdjm 9338d4658eSdjmThis is desirable, since it saves the transmission of data that would 94422225e8Sdjmotherwise need to be discarded and it allows an endpoint to signal local 95422225e8Sdjmprocesses of the condition, e.g. by closing the corresponding file 96422225e8Sdjmdescriptor. 97422225e8Sdjm 98422225e8SdjmOpenSSH implements a channel extension message to perform this 997153c228Sdjmsignalling: "eow@openssh.com" (End Of Write). This message is sent by 1007153c228Sdjman endpoint when the local output of a session channel is closed or 1017153c228Sdjmexperiences a write error. The message is formatted as follows: 102422225e8Sdjm 103422225e8Sdjm byte SSH_MSG_CHANNEL_REQUEST 104422225e8Sdjm uint32 recipient channel 105422225e8Sdjm string "eow@openssh.com" 106422225e8Sdjm boolean FALSE 107422225e8Sdjm 108422225e8SdjmOn receiving this message, the peer SHOULD cease sending data of 109422225e8Sdjmthe channel and MAY signal the process from which the channel data 110422225e8Sdjmoriginates (e.g. by closing its read file descriptor). 111422225e8Sdjm 112422225e8SdjmAs with the symmetric SSH_MSG_CHANNEL_EOF message, the channel does 113422225e8Sdjmremain open after a "eow@openssh.com" has been sent and more data may 114422225e8Sdjmstill be sent in the other direction. This message does not consume 115422225e8Sdjmwindow space and may be sent even if no window space is available. 116422225e8Sdjm 117e187e146SdjmNB. due to certain broken SSH implementations aborting upon receipt 118e187e146Sdjmof this message (in contravention of RFC4254 section 5.4), this 119e187e146Sdjmmessage is only sent to OpenSSH peers (identified by banner). 120e187e146SdjmOther SSH implementations may be whitelisted to receive this message 121e187e146Sdjmupon request. 122e187e146Sdjm 123f6c05033Sdjm2.2. connection: disallow additional sessions extension 12482046f86Sdjm "no-more-sessions@openssh.com" 12582046f86Sdjm 12682046f86SdjmMost SSH connections will only ever request a single session, but a 12782046f86Sdjmattacker may abuse a running ssh client to surreptitiously open 12882046f86Sdjmadditional sessions under their control. OpenSSH provides a global 12982046f86Sdjmrequest "no-more-sessions@openssh.com" to mitigate this attack. 13082046f86Sdjm 13182046f86SdjmWhen an OpenSSH client expects that it will never open another session 13282046f86Sdjm(i.e. it has been started with connection multiplexing disabled), it 13382046f86Sdjmwill send the following global request: 13482046f86Sdjm 13582046f86Sdjm byte SSH_MSG_GLOBAL_REQUEST 13682046f86Sdjm string "no-more-sessions@openssh.com" 13782046f86Sdjm char want-reply 13882046f86Sdjm 13982046f86SdjmOn receipt of such a message, an OpenSSH server will refuse to open 14082046f86Sdjmfuture channels of type "session" and instead immediately abort the 14182046f86Sdjmconnection. 14282046f86Sdjm 14382046f86SdjmNote that this is not a general defence against compromised clients 14482046f86Sdjm(that is impossible), but it thwarts a simple attack. 14582046f86Sdjm 146e187e146SdjmNB. due to certain broken SSH implementations aborting upon receipt 147e187e146Sdjmof this message, the no-more-sessions request is only sent to OpenSSH 148e187e146Sdjmservers (identified by banner). Other SSH implementations may be 149e187e146Sdjmwhitelisted to receive this message upon request. 150e187e146Sdjm 151f6c05033Sdjm2.3. connection: Tunnel forward extension "tun@openssh.com" 1520afb9521Sdjm 1536c9c8648SdjmOpenSSH supports layer 2 and layer 3 tunnelling via the "tun@openssh.com" 1540afb9521Sdjmchannel type. This channel type supports forwarding of network packets 1556c9c8648Sdjmwith datagram boundaries intact between endpoints equipped with 1560afb9521Sdjminterfaces like the BSD tun(4) device. Tunnel forwarding channels are 1570afb9521Sdjmrequested by the client with the following packet: 1580afb9521Sdjm 1590afb9521Sdjm byte SSH_MSG_CHANNEL_OPEN 1600afb9521Sdjm string "tun@openssh.com" 1610afb9521Sdjm uint32 sender channel 1620afb9521Sdjm uint32 initial window size 1630afb9521Sdjm uint32 maximum packet size 1640afb9521Sdjm uint32 tunnel mode 1650afb9521Sdjm uint32 remote unit number 1660afb9521Sdjm 1670afb9521SdjmThe "tunnel mode" parameter specifies whether the tunnel should forward 1680afb9521Sdjmlayer 2 frames or layer 3 packets. It may take one of the following values: 1690afb9521Sdjm 1700afb9521Sdjm SSH_TUNMODE_POINTOPOINT 1 /* layer 3 packets */ 1710afb9521Sdjm SSH_TUNMODE_ETHERNET 2 /* layer 2 frames */ 1720afb9521Sdjm 1730afb9521SdjmThe "tunnel unit number" specifies the remote interface number, or may 174c880fb56Sdjmbe 0x7fffffff to allow the server to automatically chose an interface. A 175c880fb56Sdjmserver that is not willing to open a client-specified unit should refuse 176c880fb56Sdjmthe request with a SSH_MSG_CHANNEL_OPEN_FAILURE error. On successful 177c880fb56Sdjmopen, the server should reply with SSH_MSG_CHANNEL_OPEN_SUCCESS. 1780afb9521Sdjm 1790afb9521SdjmOnce established the client and server may exchange packet or frames 1800afb9521Sdjmover the tunnel channel by encapsulating them in SSH protocol strings 1810afb9521Sdjmand sending them as channel data. This ensures that packet boundaries 1820afb9521Sdjmare kept intact. Specifically, packets are transmitted using normal 1830afb9521SdjmSSH_MSG_CHANNEL_DATA packets: 1840afb9521Sdjm 1850afb9521Sdjm byte SSH_MSG_CHANNEL_DATA 1860afb9521Sdjm uint32 recipient channel 1870afb9521Sdjm string data 1880afb9521Sdjm 1890afb9521SdjmThe contents of the "data" field for layer 3 packets is: 1900afb9521Sdjm 1910afb9521Sdjm uint32 packet length 1920afb9521Sdjm uint32 address family 1930afb9521Sdjm byte[packet length - 4] packet data 1940afb9521Sdjm 1950afb9521SdjmThe "address family" field identifies the type of packet in the message. 1960afb9521SdjmIt may be one of: 1970afb9521Sdjm 1980afb9521Sdjm SSH_TUN_AF_INET 2 /* IPv4 */ 1990afb9521Sdjm SSH_TUN_AF_INET6 24 /* IPv6 */ 2000afb9521Sdjm 2010afb9521SdjmThe "packet data" field consists of the IPv4/IPv6 datagram itself 2020afb9521Sdjmwithout any link layer header. 2030afb9521Sdjm 204c880fb56SdjmThe contents of the "data" field for layer 2 packets is: 2050afb9521Sdjm 2060afb9521Sdjm uint32 packet length 2070afb9521Sdjm byte[packet length] frame 2080afb9521Sdjm 2096c9c8648SdjmThe "frame" field contains an IEEE 802.3 Ethernet frame, including 2100afb9521Sdjmheader. 2110afb9521Sdjm 212f6c05033Sdjm3. SFTP protocol changes 213f6c05033Sdjm 214f6c05033Sdjm3.1. sftp: Reversal of arguments to SSH_FXP_SYMLINK 215422225e8Sdjm 216422225e8SdjmWhen OpenSSH's sftp-server was implemented, the order of the arguments 2176c9c8648Sdjmto the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately, 218422225e8Sdjmthe reversal was not noticed until the server was widely deployed. Since 219422225e8Sdjmfixing this to follow the specification would cause incompatibility, the 220422225e8Sdjmcurrent order was retained. For correct operation, clients should send 221422225e8SdjmSSH_FXP_SYMLINK as follows: 222422225e8Sdjm 223422225e8Sdjm uint32 id 224422225e8Sdjm string targetpath 225422225e8Sdjm string linkpath 226422225e8Sdjm 227f6c05033Sdjm3.2. sftp: Server extension announcement in SSH_FXP_VERSION 228422225e8Sdjm 229422225e8SdjmOpenSSH's sftp-server lists the extensions it supports using the 230422225e8Sdjmstandard extension announcement mechanism in the SSH_FXP_VERSION server 231422225e8Sdjmhello packet: 232422225e8Sdjm 233422225e8Sdjm uint32 3 /* protocol version */ 234422225e8Sdjm string ext1-name 235422225e8Sdjm string ext1-version 236422225e8Sdjm string ext2-name 237422225e8Sdjm string ext2-version 238422225e8Sdjm ... 239422225e8Sdjm string extN-name 240422225e8Sdjm string extN-version 241422225e8Sdjm 242422225e8SdjmEach extension reports its integer version number as an ASCII encoded 243422225e8Sdjmstring, e.g. "1". The version will be incremented if the extension is 244422225e8Sdjmever changed in an incompatible way. The server MAY advertise the same 245422225e8Sdjmextension with multiple versions (though this is unlikely). Clients MUST 2466c9c8648Sdjmcheck the version number before attempting to use the extension. 247422225e8Sdjm 248f6c05033Sdjm3.3. sftp: Extension request "posix-rename@openssh.com" 249422225e8Sdjm 250422225e8SdjmThis operation provides a rename operation with POSIX semantics, which 251422225e8Sdjmare different to those provided by the standard SSH_FXP_RENAME in 252422225e8Sdjmdraft-ietf-secsh-filexfer-02.txt. This request is implemented as a 253422225e8SdjmSSH_FXP_EXTENDED request with the following format: 254422225e8Sdjm 255422225e8Sdjm uint32 id 256422225e8Sdjm string "posix-rename@openssh.com" 257422225e8Sdjm string oldpath 258422225e8Sdjm string newpath 259422225e8Sdjm 260422225e8SdjmOn receiving this request the server will perform the POSIX operation 261422225e8Sdjmrename(oldpath, newpath) and will respond with a SSH_FXP_STATUS message. 262422225e8SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 263422225e8Sdjm"1". 264422225e8Sdjm 265f6c05033Sdjm3.4. sftp: Extension requests "statvfs@openssh.com" and 266422225e8Sdjm "fstatvfs@openssh.com" 267422225e8Sdjm 268422225e8SdjmThese requests correspond to the statvfs and fstatvfs POSIX system 269422225e8Sdjminterfaces. The "statvfs@openssh.com" request operates on an explicit 270422225e8Sdjmpathname, and is formatted as follows: 271422225e8Sdjm 272422225e8Sdjm uint32 id 273422225e8Sdjm string "statvfs@openssh.com" 274422225e8Sdjm string path 275422225e8Sdjm 276422225e8SdjmThe "fstatvfs@openssh.com" operates on an open file handle: 277422225e8Sdjm 278422225e8Sdjm uint32 id 27938d4658eSdjm string "fstatvfs@openssh.com" 280422225e8Sdjm string handle 281422225e8Sdjm 282422225e8SdjmThese requests return a SSH_FXP_STATUS reply on failure. On success they 283422225e8Sdjmreturn the following SSH_FXP_EXTENDED_REPLY reply: 284422225e8Sdjm 285422225e8Sdjm uint32 id 286f00164cfSdtucker uint64 f_bsize /* file system block size */ 287f00164cfSdtucker uint64 f_frsize /* fundamental fs block size */ 288422225e8Sdjm uint64 f_blocks /* number of blocks (unit f_frsize) */ 289422225e8Sdjm uint64 f_bfree /* free blocks in file system */ 290422225e8Sdjm uint64 f_bavail /* free blocks for non-root */ 291422225e8Sdjm uint64 f_files /* total file inodes */ 292422225e8Sdjm uint64 f_ffree /* free file inodes */ 293422225e8Sdjm uint64 f_favail /* free file inodes for to non-root */ 29433745cbfSdjm uint64 f_fsid /* file system id */ 295f00164cfSdtucker uint64 f_flag /* bit mask of f_flag values */ 296f00164cfSdtucker uint64 f_namemax /* maximum filename length */ 297422225e8Sdjm 298422225e8SdjmThe values of the f_flag bitmask are as follows: 299422225e8Sdjm 300422225e8Sdjm #define SSH_FXE_STATVFS_ST_RDONLY 0x1 /* read-only */ 301422225e8Sdjm #define SSH_FXE_STATVFS_ST_NOSUID 0x2 /* no setuid */ 302422225e8Sdjm 303fae5684aSdjmBoth the "statvfs@openssh.com" and "fstatvfs@openssh.com" extensions are 304fae5684aSdjmadvertised in the SSH_FXP_VERSION hello with version "2". 30533745cbfSdjm 3069c120764Sdjm10. sftp: Extension request "hardlink@openssh.com" 3079c120764Sdjm 3089c120764SdjmThis request is for creating a hard link to a regular file. This 3099c120764Sdjmrequest is implemented as a SSH_FXP_EXTENDED request with the 3109c120764Sdjmfollowing format: 3119c120764Sdjm 3129c120764Sdjm uint32 id 3139c120764Sdjm string "hardlink@openssh.com" 3149c120764Sdjm string oldpath 3159c120764Sdjm string newpath 3169c120764Sdjm 3179c120764SdjmOn receiving this request the server will perform the operation 3189c120764Sdjmlink(oldpath, newpath) and will respond with a SSH_FXP_STATUS message. 3199c120764SdjmThis extension is advertised in the SSH_FXP_VERSION hello with version 3209c120764Sdjm"1". 3219c120764Sdjm 322*4ea77511Sdjm$OpenBSD: PROTOCOL,v 1.19 2013/01/03 12:49:01 djm Exp $ 323