Encryption ciphers

How OpenSSH Works #1
How OpenSSH Works #2
To Configure:
nano /etc/ssh/sshd_config

# Encryption
# ----------
# The command "sshd -T | grep macs" shows the supported MAC algorithms.
# aes256-cbc uses AES in cipher-block chaining (CBC) mode, which can be vulnerable.
# aes256-gcm@openssh.com provides both encryption and authentication.
# twofish256-ctr is a good option but not widely supported.
# chacha20-poly1305@openssh.com is faster than AES, especially without AES-NI.
# Run /proc/cpuinfo to check the flags.
# Use aes256-ctr if things break.
Ciphers aes256-gcm@openssh.com

Best Choice: AES256-GCM@openssh.com

βœ… **Recommended First Choice** – Supported out of the box with OpenSSH.

AES256-GCM@openssh.com

πŸ”Ή **Authenticated Encryption (AEAD):** Combines **encryption + integrity protection**, preventing tampering and ensuring secure communications.
πŸ”Ή **Resistant to Padding Oracle Attacks:** Unlike CBC-based modes, **GCM eliminates padding vulnerabilities**.
πŸ”Ή **High Performance:** **Supports parallel processing**, making it faster than traditional block ciphers.
πŸ”Ή **Optimized for Modern Hardware:** Uses **AES-NI acceleration**, reducing CPU load while improving security.
πŸ”Ή **Trusted & Standardized:** Used in government, enterprise, and modern cryptographic implementations.

πŸ”— Alternative Secure Choices:
βœ… **Chacha20-Poly1305@openssh.com** (Faster on non-AES hardware, ideal for mobile/low-power devices)
βœ… **AES128-GCM@openssh.com** (Lower overhead but still secure if AES256 is too resource-intensive)

Paranoid Mode: serpent256-cbc

Provides **high-security encryption** but requires **significant configuration** and may impact performance. Serpent256-CBC is known for its strong encryption design, but its use in modern systems is limited due to its computational overhead.

**Why Serpent?** πŸ”
βœ… **Highly Secure:** Serpent256-CBC was one of the AES competition finalists, designed for strong cryptographic protection.
βœ… **Resistant to Cryptanalysis:** Unlike AES, Serpent uses **32 rounds of encryption**, making brute-force and differential cryptanalysis significantly harder.
βœ… **No Known Backdoors:** Unlike AES, where theoretical concerns exist about possible **NSA involvement**, Serpent remains mathematically unbroken.

**Why Not Serpent?** ⚠️
πŸ”» **Performance Trade-off:** Serpent is significantly **slower than AES** in software implementations, making it impractical for real-time encryption needs.
πŸ”» **Limited Hardware Support:** Unlike AES, Serpent lacks widespread hardware acceleration, increasing CPU load.
πŸ”» **Compatibility Issues:** Not natively supported in most modern OpenSSH builds, requiring **custom OpenSSL builds** or patches.

πŸ”— Alternative Secure Ciphers:
βœ… Twofish256-CBC (Balanced security & performance)
βœ… Serpent-CBC (For extreme security needs)

Good choice: aes256-ctr

Supported directly out of the box.

aes256-ctr
aes256-cbc (⚠️ Vulnerable to attacks: If ciphertext integrity is not verified via MAC "Message Authentication Code", attackers can exploit padding errors to decrypt or manipulate data without knowing the encryption key. This is a common issue in unauthenticated AES-CBC implementations.)

Fastest: aes128-gcm@openssh.com

Best choice when optimizing resources is needed, e.g., large file transfers.

To ensure optimal performance when transferring large files over SCP, it's important to consider the use of accelerators. Accelerators are components designed to speed up specific operations by offloading them from the main CPU. These components can be either hardware or software-based.

One example of a hardware accelerator that was commonly used in the past is the 3DES accelerator. 3DES is a symmetric-key encryption algorithm that was widely supported by hardware accelerators in the early days of SSH and SCP. The algorithm has since been superseded by the Advanced Encryption Standard (AES), which provides stronger security and is supported by modern CPUs through the AES instruction set.

Recommended Ciphers:
πŸ”Ή aes128-gcm@openssh.com βœ… (Fastest & Secure)
πŸ”Ή chacha20-poly1305@openssh.com βœ… (Lightweight Alternative)
⚠️ Warning:
πŸ”» aes128-cbc ❌ (Vulnerable to attacks: If ciphertext integrity is not verified via MAC "Message Authentication Code", attackers can exploit padding errors to decrypt or manipulate data without knowing the encryption key. This is a common issue in unauthenticated AES-CBC implementations.)

Other:

Miscellaneous ciphers that are available but may have security concerns.

⚠️ Vulnerable Ciphers:
πŸ”» twofish128-cbc ❌ (Vulnerable if ciphertext integrity is not verified via MAC)
πŸ”» serpent192-cbc ❌ (Vulnerable if ciphertext integrity is not verified via MAC)
πŸ”» serpent128-cbc ❌ (Vulnerable if ciphertext integrity is not verified via MAC)
πŸ”» blowfish-cbc ❌ (Vulnerable if ciphertext integrity is not verified via MAC)
πŸ”» cast128-cbc ❌ (Vulnerable if ciphertext integrity is not verified via MAC)
⚠️ Weak Ciphers (Avoid Using If Possible):
πŸ”Ή arcfour256 ⚠️ (Considered weak, avoid if possible)
πŸ”Ή arcfour128 ⚠️ (Considered weak, avoid if possible)

Vulnerable Ciphers - DO NOT USE:

❌ These ciphers are considered highly vulnerable and should never be used in secure environments.

⚠️ 3DES-CBC ❌ (Insecure & Deprecated)
πŸ”» Meet-in-the-Middle Attack: This vulnerability reduces brute-force complexity, allowing attackers to efficiently recover encryption keys.
πŸ”» Slow & Outdated: 3DES requires multiple encryption passes, making it slower and still weaker than modern ciphers.
πŸ”» Deprecated in OpenSSH: Officially removed from OpenSSH due to security risks.

❗ What Should You Use Instead?
βœ… **aes256-gcm@openssh.com** (Recommended for security & performance)
βœ… **chacha20-poly1305@openssh.com** (Efficient & secure, especially on resource-limited devices)