How Does SSH Work? A Step-by-Step Breakdown!
🔒 How Does SSH Work? A Step-by-Step Breakdown!
Secure Shell is an essential protocol in the tech world, enabling secure communication between devices. Here’s a visual guide to understanding the core steps of SSH:
1️⃣ Establish TCP Connection
🔻 The SSH client initiates a connection to the SSH server using TCP, typically on port 22.
🔻 This step sets up the basic communication channel between the client and the server.
2️⃣ Supported Version Negotiation
🔻 The client and server exchange their SSH protocol versions to ensure compatibility.
🔻 If a mismatch is detected, the connection is terminated.
3️⃣ Supported Algorithms Negotiation
🔻 Both parties negotiate which cryptographic algorithms to use for encryption, hashing, and key exchange (e.g., RSA, ECDSA, or ED25519).
🔻 This ensures that both the client and server use a mutually supported and secure algorithm.
4️⃣ Generate Key Pairs
🔻 The SSH client generates a key pair:
A private key, which remains secret.
A public key, which can be shared with the server for authentication.
5️⃣ Send Public Key
🔻 The client sends its public key to the SSH server for identification.
6️⃣ Initiate a Login Request
🔻 The client requests to log in to the server using the previously exchanged public key.
7️⃣ Server Finds Matching Key
🔻 The server searches for the client’s public key in its authorized keys file (~/.ssh/authorized_keys).
🔻 If the key is found, the server encrypts a challenge message using the client’s public key.
8️⃣ Return an Encrypted Random Number
🔻 The server sends the encrypted challenge (random number) back to the client for verification.
9️⃣ Decrypt Data Using Private Key
🔻 The client uses its private key to decrypt the challenge.
🔻 This proves to the server that the client holds the corresponding private key, completing the authentication process.
🔟 Send Decrypted Data
🔻 The client sends the decrypted random number back to the server.
🔻 If the decrypted value matches the server’s expectation, the client is authenticated.
1️⃣1️⃣ Verify Client’s Decryption
🔻 The server verifies the decrypted response. If correct, it establishes trust with the client.
1️⃣2️⃣Calculate Session Key
🔻 Both the client and server calculate a session key using the agreed key exchange algorithm.
🔻 This key is used to encrypt all subsequent communication.
1️⃣3️⃣ Send Encrypted Commands
🔻 Once the session is established, the client sends commands securely encrypted using the session key.
1️⃣4️⃣ Decrypt Commands Using Session Key
🔻 The server decrypts incoming commands using the session key and executes them.
1️⃣5️⃣ Send Encrypted Results
🔻 The server encrypts the command results with the session key and sends them back to the client.
1️⃣6️⃣ Decrypt Results Using Session Key
🔻 The client decrypts the response to view the result of its command execution.
Cách SSH hoạt động: Hướng dẫn từng bước!
Secure Shell (SSH) là giao thức quan trọng trong thế giới công nghệ, cho phép truyền thông bảo mật giữa các thiết bị. Dưới đây là hướng dẫn hình ảnh về các bước cốt lõi của SSH:
Các bước kết nối SSH
Thiết lập kết nối TCP: Máy khách SSH kết nối với máy chủ SSH qua TCP, thường trên cổng 22.
Đàm phán phiên bản hỗ trợ: Máy khách và máy chủ trao đổi phiên bản giao thức SSH để đảm bảo tính tương thích.
Đàm phán thuật toán hỗ trợ: Cả hai bên đàm phán thuật toán mã hóa, băm và trao đổi khóa (ví dụ: RSA, ECDSA hoặc ED25519).
Tạo cặp khóa: Máy khách tạo cặp khóa: Khóa riêng tư và khóa công khai.
Gửi khóa công khai: Máy khách gửi khóa công khai đến máy chủ SSH.
Yêu cầu đăng nhập: Máy khách yêu cầu đăng nhập vào máy chủ bằng khóa công khai.
Máy chủ tìm kiếm khóa tương ứng: Máy chủ tìm kiếm khóa công khai của máy khách trong tệp khóa được phép (~/.ssh/authorized_keys).
Trả về số ngẫu nhiên mã hóa: Máy chủ gửi số ngẫu nhiên mã hóa về máy khách.
Giải mã dữ liệu bằng khóa riêng tư: Máy khách giải mã số ngẫu nhiên bằng khóa riêng tư.
Gửi dữ liệu giải mã: Máy khách gửi số ngẫu nhiên giải mã về máy chủ.
Các bước xác thực và mã hóa
Xác thực giải mã của máy khách: Máy chủ xác thực giải mã.
Tính toán khóa phiên: Cả hai bên tính toán khóa phiên bằng thuật toán trao đổi khóa đồng ý.
Gửi lệnh mã hóa: Máy khách gửi lệnh mã hóa bằng khóa phiên.
Giải mã lệnh bằng khóa phiên: Máy chủ giải mã lệnh và thực thi.
Gửi kết quả mã hóa: Máy chủ gửi kết quả mã hóa về máy khách.
Giải mã kết quả bằng khóa phiên: Máy khách giải mã kết quả.
🧷 ByteByteGo
hashtag#SSH hashtag#SecureCommunication hashtag#Linux hashtag#ITInfrastructure
Last updated
Was this helpful?