Secure Shell
# SSH Protocol
SSH (Secure Shell) is an encrypted protocol used for secure remote login and other network services.
SSH protects data security during transmission through encrypted communication, and is widely used in system management, file transfer, and remote command execution scenarios.
## How SSH Works
SSH uses a client-server model and ensures communication security through encryption technology.
The following is the basic process for SSH connection establishment and data transmission:
### 1. **Connection Establishment**
!(#)
* The client connects to port 22 on the server (the default SSH port).
* The server sends its public key to the client.
* The client verifies the server's public key (usually through known host key fingerprints).
* The client and server negotiate encryption algorithms (such as AES, RSA, etc.).
* The client generates a session key, encrypts it with the server's public key, and sends it to the server.
* Both parties use the session key to encrypt subsequent communications.
* * *
### 2. **User Authentication**
SSH supports multiple user authentication methods, the common ones being:
* **Password Authentication**: The user enters a username and password.
* **Public Key Authentication**: The user authenticates using a private key, and the server verifies the corresponding public key.
**Password Authentication**
!(#)
* The client sends the username.
* The server requests the password.
* The client sends the encrypted password.
* The server verifies the password and returns the authentication result.
**Public Key Authentication**
!(#)
* The client sends the username and public key.
* The server sends a random number.
* The client signs the random number with the private key and sends it to the server.
* The server verifies the signature using the public key and returns the authentication result.
* * *
### 3. **Data
YouTip