📄 rfc.nroff
字号:
.\" -*- nroff -*-.\".\" $OpenBSD: RFC.nroff,v 1.2 2000/10/16 09:38:44 djm Exp $.\".pl 10.0i.po 0.ll 7.2i.lt 7.2i.nr LL 7.2i.nr LT 7.2i.ds LF Ylonen.ds RF FORMFEED[Page %].ds CF.ds LH Internet-Draft.ds RH 15 November 1995.ds CH SSH (Secure Shell) Remote Login Protocol.na.hy 0.in 0Network Working Group T. YlonenInternet-Draft Helsinki University of Technologydraft-ylonen-ssh-protocol-00.txt 15 November 1995Expires: 15 May 1996.in 3.ceThe SSH (Secure Shell) Remote Login Protocol.ti 0Status of This MemoThis document is an Internet-Draft. Internet-Drafts are workingdocuments of the Internet Engineering Task Force (IETF), its areas,and its working groups. Note that other groups may also distributeworking documents as Internet-Drafts.Internet-Drafts are draft documents valid for a maximum of sixmonths and may be updated, replaced, or obsoleted by other docu-ments at any time. It is inappropriate to use Internet-Drafts asreference material or to cite them other than as ``work in pro-gress.''To learn the current status of any Internet-Draft, please check the``1id-abstracts.txt'' listing contained in the Internet- Drafts ShadowDirectories on ftp.is.co.za (Africa), nic.nordu.net (Europe),munnari.oz.au (Pacific Rim), ds.internic.net (US East Coast), orftp.isi.edu (US West Coast).The distribution of this memo is unlimited..ti 0IntroductionSSH (Secure Shell) is a program to log into another computer over anetwork, to execute commands in a remote machine, and to move filesfrom one machine to another. It provides strong authentication andsecure communications over insecure networks. Its features includethe following:.IP oCloses several security holes (e.g., IP, routing, and DNS spoofing).New authentication methods: .rhosts together with RSA [RSA] based hostauthentication, and pure RSA authentication..IP oAll communications are automatically and transparently encrypted.Encryption is also used to protect integrity..IP oX11 connection forwarding provides secure X11 sessions..IP oArbitrary TCP/IP ports can be redirected over the encrypted channelin both directions..IP oClient RSA-authenticates the server machine in the beginning of everyconnection to prevent trojan horses (by routing or DNS spoofing) andman-in-the-middle attacks, and the server RSA-authenticates the clientmachine before accepting .rhosts or /etc/hosts.equiv authentication(to prevent DNS, routing, or IP spoofing)..IP oAn authentication agent, running in the user's local workstation orlaptop, can be used to hold the user's RSA authentication keys..RTThe goal has been to make the software as easy to use as possible forordinary users. The protocol has been designed to be as secure aspossible while making it possible to create implementations thatare easy to use and install. The sample implementation has a numberof convenient features that are not described in this document as theyare not relevant for the protocol..ti 0Overview of the ProtocolThe software consists of a server program running on a server machine,and a client program running on a client machine (plus a few auxiliaryprograms). The machines are connected by an insecure IP [RFC0791]network (that can be monitored, tampered with, and spoofed by hostileparties).A connection is always initiated by the client side. The serverlistens on a specific port waiting for connections. Many clients mayconnect to the same server machine.The client and the server are connected via a TCP/IP [RFC0793] socketthat is used for bidirectional communication. Other types oftransport can be used but are currently not defined.When the client connects the server, the server accepts the connectionand responds by sending back its version identification string. Theclient parses the server's identification, and sends its ownidentification. The purpose of the identification strings is tovalidate that the connection was to the correct port, declare theprotocol version number used, and to declare the software version usedon each side (for debugging purposes). The identification strings arehuman-readable. If either side fails to understand or support theother side's version, it closes the connection.After the protocol identification phase, both sides switch to a packetbased binary protocol. The server starts by sending its host key(every host has an RSA key used to authenticate the host), server key(an RSA key regenerated every hour), and other information to theclient. The client then generates a 256 bit session key, encrypts itusing both RSA keys (see below for details), and sends the encryptedsession key and selected cipher type to the server. Both sides thenturn on encryption using the selected algorithm and key. The serversends an encrypted confirmation message to the client.The client then authenticates itself using any of a number ofauthentication methods. The currently supported authenticationmethods are .rhosts or /etc/hosts.equiv authentication (disabled bydefault), the same with RSA-based host authentication, RSAauthentication, and password authentication.After successful authentication, the client makes a number of requeststo prepare for the session. Typical requests include allocating apseudo tty, starting X11 [X11] or TCP/IP port forwarding, startingauthentication agent forwarding, and executing the shell or a command.When a shell or command is executed, the connection enters interactivesession mode. In this mode, data is passed in both directions, new forwarded connections may be opened, etc. The interactive sessionnormally terminates when the server sends the exit status of theprogram to the client.The protocol makes several reservations for future extensibility.First of all, the initial protocol identification messages include theprotocol version number. Second, the first packet by both sidesincludes a protocol flags field, which can be used to agree onextensions in a compatible manner. Third, the authentication andsession preparation phases work so that the client sends requests tothe server, and the server responds with success or failure. If theclient sends a request that the server does not support, the serversimply returns failure for it. This permits compatible addition ofnew authentication methods and preparation operations. Theinteractive session phase, on the other hand, works asynchronously anddoes not permit the use of any extensions (because there is no easyand reliable way to signal rejection to the other side and problemswould be hard to debug). Any compatible extensions to this phase mustbe agreed upon during any of the earlier phases..ti 0The Binary Packet ProtocolAfter the protocol identification strings, both sides only sendspecially formatted packets. The packet layout is as follows:.IP oPacket length: 32 bit unsigned integer, coded as four 8-bit bytes, msbfirst. Gives the length of the packet, not including the length fieldand padding. The maximum length of a packet (not including the lengthfield and padding) is 262144 bytes..IP oPadding: 1-8 bytes of random data (or zeroes if not encrypting). Theamount of padding is (8 - (length % 8)) bytes (where % stands for themodulo operator). The rationale for always having some random paddingat the beginning of each packet is to make known plaintext attacksmore difficult..IP oPacket type: 8-bit unsigned byte. The value 255 is reserved forfuture extension..IP oData: binary data bytes, depending on the packet type. The number ofdata bytes is the "length" field minus 5..IP oCheck bytes: 32-bit crc, four 8-bit bytes, msb first. The crc is theCyclic Redundancy Check, with the polynomial 0xedb88320, of thePadding, Packet type, and Data fields. The crc is computed beforeany encryption..RTThe packet, except for the length field, may be encrypted using any ofa number of algorithms. The length of the encrypted part (Padding +Type + Data + Check) is always a multiple of 8 bytes. Typically thecipher is used in a chained mode, with all packets chained together asif it was a single data stream (the length field is never included inthe encryption process). Details of encryption are described below.When the session starts, encryption is turned off. Encryption isenabled after the client has sent the session key. The encryptionalgorithm to use is selected by the client..ti 0Packet CompressionIf compression is supported (it is an optional feature, seeSSH_CMSG_REQUEST_COMPRESSION below), the packet type and data fieldsof the packet are compressed using the gzip deflate algorithm [GZIP].If compression is in effect, the packet length field indicates thelength of the compressed data, plus 4 for the crc. The amount ofpadding is computed from the compressed data, so that the amount ofdata to be encrypted becomes a multiple of 8 bytes.When compressing, the packets (type + data portions) in each directionare compressed as if they formed a continuous data stream, with only thecurrent compression block flushed between packets. This correspondsto the GNU ZLIB library Z_PARTIAL_FLUSH option. The compressiondictionary is not flushed between packets. The two directions arecompressed independently of each other..ti 0Packet EncryptionThe protocol supports several encryption methods. During sessioninitialization, the server sends a bitmask of all encryption methodsthat it supports, and the client selects one of these methods. Theclient also generates a 256-bit random session key (32 8-bit bytes) andsends it to the server.The encryption methods supported by the current implementation, andtheir codes are:.TScenter;l r l.SSH_CIPHER_NONE 0 No encryptionSSH_CIPHER_IDEA 1 IDEA in CFB modeSSH_CIPHER_DES 2 DES in CBC modeSSH_CIPHER_3DES 3 Triple-DES in CBC modeSSH_CIPHER_TSS 4 An experimental stream cipherSSH_CIPHER_RC4 5 RC4.TEAll implementations are required to support SSH_CIPHER_DES andSSH_CIPHER_3DES. Supporting SSH_CIPHER_IDEA, SSH_CIPHER_RC4, andSSH_CIPHER_NONE is recommended. Support for SSH_CIPHER_TSS isoptional (and it is not described in this document). Other ciphersmay be added at a later time; support for them is optional.For encryption, the encrypted portion of the packet is considered alinear byte stream. The length of the stream is always a multiple of8. The encrypted portions of consecutive packets (in the samedirection) are encrypted as if they were a continuous buffer (that is,any initialization vectors are passed from the previous packet to thenext packet). Data in each direction is encrypted independently..IP SSH_CIPHER_DESThe key is taken from the first 8 bytes of the session key. The leastsignificant bit of each byte is ignored. This results in 56 bits ofkey data. DES [DES] is used in CBC mode. The iv (initialization vector) isinitialized to all zeroes..IP SSH_CIPHER_3DESThe variant of triple-DES used here works as follows: there are threeindependent DES-CBC ciphers, with independent initialization vectors.The data (the whole encrypted data stream) is first encrypted with thefirst cipher, then decrypted with the second cipher, and finallyencrypted with the third cipher. All these operations are performedin CBC mode.The key for the first cipher is taken from the first 8 bytes of thesession key; the key for the next cipher from the next 8 bytes, andthe key for the third cipher from the following 8 bytes. All threeinitialization vectors are initialized to zero.(Note: the variant of 3DES used here differs from some otherdescriptions.).IP SSH_CIPHER_IDEAThe key is taken from the first 16 bytes of the session key. IDEA[IDEA] is used in CFB mode. The initialization vector is initializedto all zeroes..IP SSH_CIPHER_TSSAll 32 bytes of the session key are used as the key.There is no reference available for the TSS algorithm; it is currentlyonly documented in the sample implementation source code. Thesecurity of this cipher is unknown (but it is quite fast). The cipheris basically a stream cipher that uses MD5 as a random numbergenerator and takes feedback from the data..IP SSH_CIPHER_RC4The first 16 bytes of the session key are used as the key for theserver to client direction. The remaining 16 bytes are used as thekey for the client to server direction. This gives independent128-bit keys for each direction.This algorithm is the alleged RC4 cipher posted to the Usenet in 1995.It is widely believed to be equivalent with the original RSADSI RC4cipher. This is a very fast algorithm..RT.ti 0Data Type EncodingsThe Data field of each packet contains data encoded as described inthis section. There may be several data items; each item is coded asdescribed here, and their representations are concatenated together(without any alignment or padding).Each data type is stored as follows:.IP "8-bit byte"The byte is stored directly as a single byte..IP "32-bit unsigned integer"Stored in 4 bytes, msb first..IP "Arbitrary length binary string"First 4 bytes are the length of the string, msb first (not includingthe length itself). The following "length" bytes are the stringvalue. There are no terminating null characters..IP "Multiple-precision integer"First 2 bytes are the number of bits in the integer, msb first (for
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -