1d4af9e69SDag-Erling SmørgravThis documents OpenSSH's deviations and extensions to the published SSH 2d4af9e69SDag-Erling Smørgravprotocol. 3d4af9e69SDag-Erling Smørgrav 4d4af9e69SDag-Erling SmørgravNote that OpenSSH's sftp and sftp-server implement revision 3 of the SSH 5d4af9e69SDag-Erling Smørgravfilexfer protocol described in: 6d4af9e69SDag-Erling Smørgrav 7d4af9e69SDag-Erling Smørgravhttp://www.openssh.com/txt/draft-ietf-secsh-filexfer-02.txt 8d4af9e69SDag-Erling Smørgrav 9b15c8340SDag-Erling SmørgravNewer versions of the draft will not be supported, though some features 10b15c8340SDag-Erling Smørgravare individually implemented as extensions described below. 11d4af9e69SDag-Erling Smørgrav 12d4af9e69SDag-Erling SmørgravThe protocol used by OpenSSH's ssh-agent is described in the file 13d4af9e69SDag-Erling SmørgravPROTOCOL.agent 14d4af9e69SDag-Erling Smørgrav 15d4af9e69SDag-Erling Smørgrav1. transport: Protocol 2 MAC algorithm "umac-64@openssh.com" 16d4af9e69SDag-Erling Smørgrav 17d4af9e69SDag-Erling SmørgravThis is a new transport-layer MAC method using the UMAC algorithm 18d4af9e69SDag-Erling Smørgrav(rfc4418). This method is identical to the "umac-64" method documented 19d4af9e69SDag-Erling Smørgravin: 20d4af9e69SDag-Erling Smørgrav 21d4af9e69SDag-Erling Smørgravhttp://www.openssh.com/txt/draft-miller-secsh-umac-01.txt 22d4af9e69SDag-Erling Smørgrav 23d4af9e69SDag-Erling Smørgrav2. transport: Protocol 2 compression algorithm "zlib@openssh.com" 24d4af9e69SDag-Erling Smørgrav 25d4af9e69SDag-Erling SmørgravThis transport-layer compression method uses the zlib compression 26d4af9e69SDag-Erling Smørgravalgorithm (identical to the "zlib" method in rfc4253), but delays the 27d4af9e69SDag-Erling Smørgravstart of compression until after authentication has completed. This 28d4af9e69SDag-Erling Smørgravavoids exposing compression code to attacks from unauthenticated users. 29d4af9e69SDag-Erling Smørgrav 30d4af9e69SDag-Erling SmørgravThe method is documented in: 31d4af9e69SDag-Erling Smørgrav 32d4af9e69SDag-Erling Smørgravhttp://www.openssh.com/txt/draft-miller-secsh-compression-delayed-00.txt 33d4af9e69SDag-Erling Smørgrav 34b15c8340SDag-Erling Smørgrav3. transport: New public key algorithms "ssh-rsa-cert-v00@openssh.com" and 35b15c8340SDag-Erling Smørgrav "ssh-dsa-cert-v00@openssh.com" 36b15c8340SDag-Erling Smørgrav 37b15c8340SDag-Erling SmørgravOpenSSH introduces two new public key algorithms to support certificate 38b15c8340SDag-Erling Smørgravauthentication for users and hostkeys. These methods are documented in 39b15c8340SDag-Erling Smørgravthe file PROTOCOL.certkeys 40b15c8340SDag-Erling Smørgrav 41b15c8340SDag-Erling Smørgrav4. connection: Channel write close extension "eow@openssh.com" 42d4af9e69SDag-Erling Smørgrav 43d4af9e69SDag-Erling SmørgravThe SSH connection protocol (rfc4254) provides the SSH_MSG_CHANNEL_EOF 44d4af9e69SDag-Erling Smørgravmessage to allow an endpoint to signal its peer that it will send no 45d4af9e69SDag-Erling Smørgravmore data over a channel. Unfortunately, there is no symmetric way for 46d4af9e69SDag-Erling Smørgravan endpoint to request that its peer should cease sending data to it 47d4af9e69SDag-Erling Smørgravwhile still keeping the channel open for the endpoint to send data to 48d4af9e69SDag-Erling Smørgravthe peer. 49d4af9e69SDag-Erling Smørgrav 50d4af9e69SDag-Erling SmørgravThis is desirable, since it saves the transmission of data that would 51d4af9e69SDag-Erling Smørgravotherwise need to be discarded and it allows an endpoint to signal local 52d4af9e69SDag-Erling Smørgravprocesses of the condition, e.g. by closing the corresponding file 53d4af9e69SDag-Erling Smørgravdescriptor. 54d4af9e69SDag-Erling Smørgrav 55d4af9e69SDag-Erling SmørgravOpenSSH implements a channel extension message to perform this 56d4af9e69SDag-Erling Smørgravsignalling: "eow@openssh.com" (End Of Write). This message is sent by 57d4af9e69SDag-Erling Smørgravan endpoint when the local output of a session channel is closed or 58d4af9e69SDag-Erling Smørgravexperiences a write error. The message is formatted as follows: 59d4af9e69SDag-Erling Smørgrav 60d4af9e69SDag-Erling Smørgrav byte SSH_MSG_CHANNEL_REQUEST 61d4af9e69SDag-Erling Smørgrav uint32 recipient channel 62d4af9e69SDag-Erling Smørgrav string "eow@openssh.com" 63d4af9e69SDag-Erling Smørgrav boolean FALSE 64d4af9e69SDag-Erling Smørgrav 65d4af9e69SDag-Erling SmørgravOn receiving this message, the peer SHOULD cease sending data of 66d4af9e69SDag-Erling Smørgravthe channel and MAY signal the process from which the channel data 67d4af9e69SDag-Erling Smørgravoriginates (e.g. by closing its read file descriptor). 68d4af9e69SDag-Erling Smørgrav 69d4af9e69SDag-Erling SmørgravAs with the symmetric SSH_MSG_CHANNEL_EOF message, the channel does 70d4af9e69SDag-Erling Smørgravremain open after a "eow@openssh.com" has been sent and more data may 71d4af9e69SDag-Erling Smørgravstill be sent in the other direction. This message does not consume 72d4af9e69SDag-Erling Smørgravwindow space and may be sent even if no window space is available. 73d4af9e69SDag-Erling Smørgrav 74cce7d346SDag-Erling SmørgravNB. due to certain broken SSH implementations aborting upon receipt 75cce7d346SDag-Erling Smørgravof this message (in contravention of RFC4254 section 5.4), this 76cce7d346SDag-Erling Smørgravmessage is only sent to OpenSSH peers (identified by banner). 77cce7d346SDag-Erling SmørgravOther SSH implementations may be whitelisted to receive this message 78cce7d346SDag-Erling Smørgravupon request. 79cce7d346SDag-Erling Smørgrav 80b15c8340SDag-Erling Smørgrav5. connection: disallow additional sessions extension 81d4af9e69SDag-Erling Smørgrav "no-more-sessions@openssh.com" 82d4af9e69SDag-Erling Smørgrav 83d4af9e69SDag-Erling SmørgravMost SSH connections will only ever request a single session, but a 84d4af9e69SDag-Erling Smørgravattacker may abuse a running ssh client to surreptitiously open 85d4af9e69SDag-Erling Smørgravadditional sessions under their control. OpenSSH provides a global 86d4af9e69SDag-Erling Smørgravrequest "no-more-sessions@openssh.com" to mitigate this attack. 87d4af9e69SDag-Erling Smørgrav 88d4af9e69SDag-Erling SmørgravWhen an OpenSSH client expects that it will never open another session 89d4af9e69SDag-Erling Smørgrav(i.e. it has been started with connection multiplexing disabled), it 90d4af9e69SDag-Erling Smørgravwill send the following global request: 91d4af9e69SDag-Erling Smørgrav 92d4af9e69SDag-Erling Smørgrav byte SSH_MSG_GLOBAL_REQUEST 93d4af9e69SDag-Erling Smørgrav string "no-more-sessions@openssh.com" 94d4af9e69SDag-Erling Smørgrav char want-reply 95d4af9e69SDag-Erling Smørgrav 96d4af9e69SDag-Erling SmørgravOn receipt of such a message, an OpenSSH server will refuse to open 97d4af9e69SDag-Erling Smørgravfuture channels of type "session" and instead immediately abort the 98d4af9e69SDag-Erling Smørgravconnection. 99d4af9e69SDag-Erling Smørgrav 100d4af9e69SDag-Erling SmørgravNote that this is not a general defence against compromised clients 101d4af9e69SDag-Erling Smørgrav(that is impossible), but it thwarts a simple attack. 102d4af9e69SDag-Erling Smørgrav 103cce7d346SDag-Erling SmørgravNB. due to certain broken SSH implementations aborting upon receipt 104cce7d346SDag-Erling Smørgravof this message, the no-more-sessions request is only sent to OpenSSH 105cce7d346SDag-Erling Smørgravservers (identified by banner). Other SSH implementations may be 106cce7d346SDag-Erling Smørgravwhitelisted to receive this message upon request. 107cce7d346SDag-Erling Smørgrav 108b15c8340SDag-Erling Smørgrav6. connection: Tunnel forward extension "tun@openssh.com" 109d4af9e69SDag-Erling Smørgrav 110d4af9e69SDag-Erling SmørgravOpenSSH supports layer 2 and layer 3 tunnelling via the "tun@openssh.com" 111d4af9e69SDag-Erling Smørgravchannel type. This channel type supports forwarding of network packets 112d4af9e69SDag-Erling Smørgravwith datagram boundaries intact between endpoints equipped with 113d4af9e69SDag-Erling Smørgravinterfaces like the BSD tun(4) device. Tunnel forwarding channels are 114d4af9e69SDag-Erling Smørgravrequested by the client with the following packet: 115d4af9e69SDag-Erling Smørgrav 116d4af9e69SDag-Erling Smørgrav byte SSH_MSG_CHANNEL_OPEN 117d4af9e69SDag-Erling Smørgrav string "tun@openssh.com" 118d4af9e69SDag-Erling Smørgrav uint32 sender channel 119d4af9e69SDag-Erling Smørgrav uint32 initial window size 120d4af9e69SDag-Erling Smørgrav uint32 maximum packet size 121d4af9e69SDag-Erling Smørgrav uint32 tunnel mode 122d4af9e69SDag-Erling Smørgrav uint32 remote unit number 123d4af9e69SDag-Erling Smørgrav 124d4af9e69SDag-Erling SmørgravThe "tunnel mode" parameter specifies whether the tunnel should forward 125d4af9e69SDag-Erling Smørgravlayer 2 frames or layer 3 packets. It may take one of the following values: 126d4af9e69SDag-Erling Smørgrav 127d4af9e69SDag-Erling Smørgrav SSH_TUNMODE_POINTOPOINT 1 /* layer 3 packets */ 128d4af9e69SDag-Erling Smørgrav SSH_TUNMODE_ETHERNET 2 /* layer 2 frames */ 129d4af9e69SDag-Erling Smørgrav 130d4af9e69SDag-Erling SmørgravThe "tunnel unit number" specifies the remote interface number, or may 131b15c8340SDag-Erling Smørgravbe 0x7fffffff to allow the server to automatically chose an interface. A 132b15c8340SDag-Erling Smørgravserver that is not willing to open a client-specified unit should refuse 133b15c8340SDag-Erling Smørgravthe request with a SSH_MSG_CHANNEL_OPEN_FAILURE error. On successful 134b15c8340SDag-Erling Smørgravopen, the server should reply with SSH_MSG_CHANNEL_OPEN_SUCCESS. 135d4af9e69SDag-Erling Smørgrav 136d4af9e69SDag-Erling SmørgravOnce established the client and server may exchange packet or frames 137d4af9e69SDag-Erling Smørgravover the tunnel channel by encapsulating them in SSH protocol strings 138d4af9e69SDag-Erling Smørgravand sending them as channel data. This ensures that packet boundaries 139d4af9e69SDag-Erling Smørgravare kept intact. Specifically, packets are transmitted using normal 140d4af9e69SDag-Erling SmørgravSSH_MSG_CHANNEL_DATA packets: 141d4af9e69SDag-Erling Smørgrav 142d4af9e69SDag-Erling Smørgrav byte SSH_MSG_CHANNEL_DATA 143d4af9e69SDag-Erling Smørgrav uint32 recipient channel 144d4af9e69SDag-Erling Smørgrav string data 145d4af9e69SDag-Erling Smørgrav 146d4af9e69SDag-Erling SmørgravThe contents of the "data" field for layer 3 packets is: 147d4af9e69SDag-Erling Smørgrav 148d4af9e69SDag-Erling Smørgrav uint32 packet length 149d4af9e69SDag-Erling Smørgrav uint32 address family 150d4af9e69SDag-Erling Smørgrav byte[packet length - 4] packet data 151d4af9e69SDag-Erling Smørgrav 152d4af9e69SDag-Erling SmørgravThe "address family" field identifies the type of packet in the message. 153d4af9e69SDag-Erling SmørgravIt may be one of: 154d4af9e69SDag-Erling Smørgrav 155d4af9e69SDag-Erling Smørgrav SSH_TUN_AF_INET 2 /* IPv4 */ 156d4af9e69SDag-Erling Smørgrav SSH_TUN_AF_INET6 24 /* IPv6 */ 157d4af9e69SDag-Erling Smørgrav 158d4af9e69SDag-Erling SmørgravThe "packet data" field consists of the IPv4/IPv6 datagram itself 159d4af9e69SDag-Erling Smørgravwithout any link layer header. 160d4af9e69SDag-Erling Smørgrav 161b15c8340SDag-Erling SmørgravThe contents of the "data" field for layer 2 packets is: 162d4af9e69SDag-Erling Smørgrav 163d4af9e69SDag-Erling Smørgrav uint32 packet length 164d4af9e69SDag-Erling Smørgrav byte[packet length] frame 165d4af9e69SDag-Erling Smørgrav 166d4af9e69SDag-Erling SmørgravThe "frame" field contains an IEEE 802.3 Ethernet frame, including 167d4af9e69SDag-Erling Smørgravheader. 168d4af9e69SDag-Erling Smørgrav 169b15c8340SDag-Erling Smørgrav7. sftp: Reversal of arguments to SSH_FXP_SYMLINK 170d4af9e69SDag-Erling Smørgrav 171d4af9e69SDag-Erling SmørgravWhen OpenSSH's sftp-server was implemented, the order of the arguments 172d4af9e69SDag-Erling Smørgravto the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately, 173d4af9e69SDag-Erling Smørgravthe reversal was not noticed until the server was widely deployed. Since 174d4af9e69SDag-Erling Smørgravfixing this to follow the specification would cause incompatibility, the 175d4af9e69SDag-Erling Smørgravcurrent order was retained. For correct operation, clients should send 176d4af9e69SDag-Erling SmørgravSSH_FXP_SYMLINK as follows: 177d4af9e69SDag-Erling Smørgrav 178d4af9e69SDag-Erling Smørgrav uint32 id 179d4af9e69SDag-Erling Smørgrav string targetpath 180d4af9e69SDag-Erling Smørgrav string linkpath 181d4af9e69SDag-Erling Smørgrav 182b15c8340SDag-Erling Smørgrav8. sftp: Server extension announcement in SSH_FXP_VERSION 183d4af9e69SDag-Erling Smørgrav 184d4af9e69SDag-Erling SmørgravOpenSSH's sftp-server lists the extensions it supports using the 185d4af9e69SDag-Erling Smørgravstandard extension announcement mechanism in the SSH_FXP_VERSION server 186d4af9e69SDag-Erling Smørgravhello packet: 187d4af9e69SDag-Erling Smørgrav 188d4af9e69SDag-Erling Smørgrav uint32 3 /* protocol version */ 189d4af9e69SDag-Erling Smørgrav string ext1-name 190d4af9e69SDag-Erling Smørgrav string ext1-version 191d4af9e69SDag-Erling Smørgrav string ext2-name 192d4af9e69SDag-Erling Smørgrav string ext2-version 193d4af9e69SDag-Erling Smørgrav ... 194d4af9e69SDag-Erling Smørgrav string extN-name 195d4af9e69SDag-Erling Smørgrav string extN-version 196d4af9e69SDag-Erling Smørgrav 197d4af9e69SDag-Erling SmørgravEach extension reports its integer version number as an ASCII encoded 198d4af9e69SDag-Erling Smørgravstring, e.g. "1". The version will be incremented if the extension is 199d4af9e69SDag-Erling Smørgravever changed in an incompatible way. The server MAY advertise the same 200d4af9e69SDag-Erling Smørgravextension with multiple versions (though this is unlikely). Clients MUST 201d4af9e69SDag-Erling Smørgravcheck the version number before attempting to use the extension. 202d4af9e69SDag-Erling Smørgrav 203b15c8340SDag-Erling Smørgrav9. sftp: Extension request "posix-rename@openssh.com" 204d4af9e69SDag-Erling Smørgrav 205d4af9e69SDag-Erling SmørgravThis operation provides a rename operation with POSIX semantics, which 206d4af9e69SDag-Erling Smørgravare different to those provided by the standard SSH_FXP_RENAME in 207d4af9e69SDag-Erling Smørgravdraft-ietf-secsh-filexfer-02.txt. This request is implemented as a 208d4af9e69SDag-Erling SmørgravSSH_FXP_EXTENDED request with the following format: 209d4af9e69SDag-Erling Smørgrav 210d4af9e69SDag-Erling Smørgrav uint32 id 211d4af9e69SDag-Erling Smørgrav string "posix-rename@openssh.com" 212d4af9e69SDag-Erling Smørgrav string oldpath 213d4af9e69SDag-Erling Smørgrav string newpath 214d4af9e69SDag-Erling Smørgrav 215d4af9e69SDag-Erling SmørgravOn receiving this request the server will perform the POSIX operation 216d4af9e69SDag-Erling Smørgravrename(oldpath, newpath) and will respond with a SSH_FXP_STATUS message. 217d4af9e69SDag-Erling SmørgravThis extension is advertised in the SSH_FXP_VERSION hello with version 218d4af9e69SDag-Erling Smørgrav"1". 219d4af9e69SDag-Erling Smørgrav 220b15c8340SDag-Erling Smørgrav10. sftp: Extension requests "statvfs@openssh.com" and 221d4af9e69SDag-Erling Smørgrav "fstatvfs@openssh.com" 222d4af9e69SDag-Erling Smørgrav 223d4af9e69SDag-Erling SmørgravThese requests correspond to the statvfs and fstatvfs POSIX system 224d4af9e69SDag-Erling Smørgravinterfaces. The "statvfs@openssh.com" request operates on an explicit 225d4af9e69SDag-Erling Smørgravpathname, and is formatted as follows: 226d4af9e69SDag-Erling Smørgrav 227d4af9e69SDag-Erling Smørgrav uint32 id 228d4af9e69SDag-Erling Smørgrav string "statvfs@openssh.com" 229d4af9e69SDag-Erling Smørgrav string path 230d4af9e69SDag-Erling Smørgrav 231d4af9e69SDag-Erling SmørgravThe "fstatvfs@openssh.com" operates on an open file handle: 232d4af9e69SDag-Erling Smørgrav 233d4af9e69SDag-Erling Smørgrav uint32 id 234d4af9e69SDag-Erling Smørgrav string "fstatvfs@openssh.com" 235d4af9e69SDag-Erling Smørgrav string handle 236d4af9e69SDag-Erling Smørgrav 237d4af9e69SDag-Erling SmørgravThese requests return a SSH_FXP_STATUS reply on failure. On success they 238d4af9e69SDag-Erling Smørgravreturn the following SSH_FXP_EXTENDED_REPLY reply: 239d4af9e69SDag-Erling Smørgrav 240d4af9e69SDag-Erling Smørgrav uint32 id 241d4af9e69SDag-Erling Smørgrav uint64 f_bsize /* file system block size */ 242d4af9e69SDag-Erling Smørgrav uint64 f_frsize /* fundamental fs block size */ 243d4af9e69SDag-Erling Smørgrav uint64 f_blocks /* number of blocks (unit f_frsize) */ 244d4af9e69SDag-Erling Smørgrav uint64 f_bfree /* free blocks in file system */ 245d4af9e69SDag-Erling Smørgrav uint64 f_bavail /* free blocks for non-root */ 246d4af9e69SDag-Erling Smørgrav uint64 f_files /* total file inodes */ 247d4af9e69SDag-Erling Smørgrav uint64 f_ffree /* free file inodes */ 248d4af9e69SDag-Erling Smørgrav uint64 f_favail /* free file inodes for to non-root */ 249d4af9e69SDag-Erling Smørgrav uint64 f_fsid /* file system id */ 250d4af9e69SDag-Erling Smørgrav uint64 f_flag /* bit mask of f_flag values */ 251d4af9e69SDag-Erling Smørgrav uint64 f_namemax /* maximum filename length */ 252d4af9e69SDag-Erling Smørgrav 253d4af9e69SDag-Erling SmørgravThe values of the f_flag bitmask are as follows: 254d4af9e69SDag-Erling Smørgrav 255d4af9e69SDag-Erling Smørgrav #define SSH_FXE_STATVFS_ST_RDONLY 0x1 /* read-only */ 256d4af9e69SDag-Erling Smørgrav #define SSH_FXE_STATVFS_ST_NOSUID 0x2 /* no setuid */ 257d4af9e69SDag-Erling Smørgrav 258d4af9e69SDag-Erling SmørgravBoth the "statvfs@openssh.com" and "fstatvfs@openssh.com" extensions are 259d4af9e69SDag-Erling Smørgravadvertised in the SSH_FXP_VERSION hello with version "2". 260d4af9e69SDag-Erling Smørgrav 261b15c8340SDag-Erling Smørgrav$OpenBSD: PROTOCOL,v 1.15 2010/02/26 20:29:54 djm Exp $ 262