OpenSSH is a free and open source implementation of SSH (Secure Shell) protocol. SSH protocol series can be used for remote control or file transfer between computers. Traditional ways to realize this function, such as telnet (Terminal Simulation Protocol), rcp ftp, rlogin and rsh, are extremely insecure, and passwords will be transmitted in clear text. OpenSSH provides server-side background programs and client tools to encrypt data during remote control and file transfer, thus replacing the original similar services.
Previously, we used rsh and telnet, because the data including ID and password were transmitted to the network without encryption when logging in, which caused security problems. Even if it is an intranet, there are dangers such as network theft and tampering. SSH encrypts all data, including passwords, for more secure remote operation. In SSH, there are two different versions of SSH 1 and SSH2 due to different protocol standards. SSH2 was developed to avoid the licensing problem of the encryption algorithm used by SSH 1 (now this licensing problem no longer exists). As an application program for installing SSH protocol, TLES 8 adopts OpenSSH, an open source. OpenSSH can correspond to any protocol of SSH 1 and SSH2, but SSH2 is used by default.
SSH mainly consists of three parts:
At the same time, SSH protocol framework also provides extended support for many advanced network security application protocols. The hierarchical relationship between them can be represented by the following figure:
For a protocol like SSH, which aims to provide secure communication, a complete key mechanism is essential. Because SSH protocol is oriented to the access and information exchange between hosts in Internet network, host key becomes the basic key mechanism. In other words, SSH protocol requires that each host using this protocol must have at least one host key pair of its own, and the service provider can only allow its connection request after authenticating the client's host key. A host can use multiple keys, and there can be different keys for different key algorithms, but at least one key is needed, that is, the key generated by DSS algorithm. For DSS algorithm, please refer to FIPS- 186 file. There are two management schemes for host key authentication in SSH protocol, as shown in the following figure:
Each host must have its own host key, and there can be multiple pairs of keys. Each host key pair includes a public key and a private key. How to use these keys in practical applications and rely on them to achieve security features? As shown in the above figure, two schemes are proposed in the SSH protocol framework.
In the first scheme, the host distributes its public key to related clients, and the clients use the host's public key to encrypt data when accessing the host, and the host uses its private key to decrypt data, thus realizing the authentication of the host key and determining the reliable identity of the client. As can be seen from Figure 2(a), the user initiates an operation from host A to access host B and host C. At this time, A becomes the client, and it must configure the public keys of host B and host C in advance, and look up the corresponding public keys according to the host name when accessing. For the accessed host (that is, the server), it is only necessary to ensure the safe storage of its own private key.
In the second scheme, there is a key authentication center. All hosts providing services in the system submit their own public keys to the authentication center, and any host as a client only needs to keep one copy of the public key of the authentication center. In this mode, before accessing the server host, the client must also request authentication from the key certification center before connecting to the destination host correctly.
Obviously, the first method is easy to implement, but maintaining the key on the client is a hassle, because every change must be reflected to the client; The second method perfectly solves the management and maintenance problems. However, this model has high requirements for certification centers. To realize such centralized authentication on the Internet, it is a big trouble just to determine the authority. Who can decide everything? However, in the long run, it is necessary to adopt centralized certification scheme in the fields of enterprise application and commercial application.
In addition, the SSH protocol framework also allows the disclosure of the host key, that is, the first access without authentication. Authentication-free first access means that when a client accesses a host for the first time, the host does not check the host key, but issues a public key to the client, so that the key must be used in future access, otherwise it will be considered illegal and its access will be denied.
In the whole communication process, in order to realize the secure connection of SSH, the server and the client have to go through the following five stages:
* At the stage of version number negotiation, SSH currently includes SSH 1 and SSH2, and both parties determine the version to be used through version negotiation.
* In the key and algorithm negotiation stage, SSH supports a variety of encryption algorithms, and both parties negotiate the final algorithm according to the algorithms supported by the local side and the peer side.
* Authentication stage: SSH client initiates authentication request to the server, and the server authenticates the client.
* Session request stage, after authentication, the client sends a session request to the server.
* Interactive session stage, after the session request is passed, the server and the client exchange information.
Q1:versions and differences of ssh.
SSH2 avoids the patent problems of RSA and fixes the defects of CRC. SSH2 replaces RSA with digital signature algorithm (DSA) and Diffie-Hellman(DH) to exchange symmetric keys, and HMAC replaces CRC. At the same time, SSH2 adds symmetric encryption algorithms such as AES and Twofish.
A 1: SSH (secure shell) has two incompatible versions so far-ssh1and SSH2. SSH 1 is divided into 1.3 and 1.5 versions. SSH 1 uses DES, 3DES, Blowfish, RC4 and other symmetric encryption algorithms to protect data security transmission, while the keys of symmetric encryption algorithms are exchanged through asymmetric encryption algorithm (RSA). SSH 1 uses Cyclic Redundancy Check Code (CRC) to ensure the integrity of data, but this method was later found to be flawed.
For more information, please refer to SSHv 1 protocol and SSHv2 protocol.
Q2: What is HMAC?
A2: HMAC (Hash Message Authentication Code), the authentication protocol of key-based hash algorithm. The principle of message authentication code is to use public functions and keys to generate a fixed-length value as an authentication identifier, and use this identifier to authenticate the integrity of the message. Use a key to generate a small data block with a fixed size, that is, MAC, add it to the message, and then transmit it. The receiver authenticates with the key shared with the sender, and so on.
Q3: What is X11forwarding?
The X 1 1 forwarding function of A3: sh enables X clients and X servers to communicate securely. After forwarding with X 1 1, the data from X client to X server is sent to ssh server first, and ssh server forwards it to ssh client by using the secure channel with ssh client, and then ssh client forwards it to X server. The data flow from the X server to the X client is the same. Here, ssh server and ssh client act as data relays between X client and X server. Because ssh server and X client, ssh client and X server are generally on the same machine, it is a kind of secure interprocess communication, and the communication between ssh server and ssh client is also secure, so the communication between X client and X server is secure.
Question 4: What is TTY?
A4: Terminal is a character-based device, which has many types. Tty is usually used to refer to various types of terminal equipment for short. Tty is short for teletype. Teletypewriter is the earliest terminal equipment, much like teletypewriter, which is produced by telex company. The device name is placed in a special file directory /dev/.
Q5: Describe briefly the process of SSH operation?