Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบเครือข่าย >> ความปลอดภัยเครือข่าย

PPK ใน Network Security ย่อมาจากอะไร? ความหมาย และการใช้งานกับ PuTTY/SFTP

PPK ย่อมาจากอะไร?

ในบริบท Network Security / SSH / Cryptography:

  • PPK = PuTTY Private Key — รูปแบบไฟล์ Private Key เฉพาะของ PuTTY (SSH Client สำหรับ Windows)
  • นามสกุลไฟล์: .ppk
  • ไม่ใช่ Standard OpenSSH Format (PEM/OpenSSH Private Key)

PPK vs PEM / OpenSSH Key Format

คุณสมบัติPPK (PuTTY)PEM / OpenSSH
ใช้กับPuTTY, WinSCP, FileZilla (Windows), Pageant (SSH Agent)OpenSSH (Linux/macOS/Windows 10+), Git, Ansible, Terraform, AWS/Azure/GCP CLI
รูปแบบProprietary (Text-based, มี Header/Footer เฉพาะ)Standard (RFC 4716 / PKCS#8), Base64 Encoded
EncryptionPuTTY's Own (AES-256-CBC + SHA1)AES-256-CBC, AES-256-GCM, ChaCha20-Poly1305 (OpenSSH New Format)
ความเข้ากันได้Windows-centric ToolsCross-platform, Industry Standard

เมื่อไหร่ต้องใช้ PPK?

  • ใช้ PuTTY SSH ไป Linux Server
  • ใช้ WinSCP / FileZilla (SFTP) บน Windows
  • ใช้ Pageant (PuTTY Authentication Agent) เก็บ Key ใน Memory
  • Legacy Windows Tools ที่ไม่รองรับ OpenSSH Key Format

วิธีสร้าง PPK (PuTTYgen)

  1. ดาวน์โหลด PuTTYgen (มาพร้อม PuTTY Installer หรือแยกต่างหาก)
  2. Generate: Key Type = Ed25519 (แนะนำ) หรือ RSA 4096 / ECDSA P-256
  3. Generate → Move Mouse สุ่ม Entropy
  4. Key Comment: ใส่ Identifier (เช่น user@host-2024)
  5. Key Passphrase: ตั้ง Passphrase แน่ๆ (Encrypt Private Key)
  6. Save Private Key: mykey.ppk
  7. Save Public Key: mykey.pub (Format รองรับ OpenSSH `ssh-rsa AAAA...` / `ssh-ed25519 AAAA...`)

แปลง PPK ↔ OpenSSH (PEM) Format

PPK → OpenSSH (Linux/macOS/Git/Ansible)

  1. PuTTYgen → Load .ppk → ใส่ Passphrase
  2. Menu Conversions → Export OpenSSH Key
  3. Save เป็น id_ed25519 หรือ id_rsa (ไม่ต้องมี Extension)
  4. ย้ายไป ~/.ssh/ → `chmod 600 id_ed25519`

OpenSSH → PPK (PuTTY/WinSCP/FileZilla)

  1. PuTTYgen → Conversions → Import Key → เลือก id_ed25519 / id_rsa
  2. ใส่ Passphrase เดิม
  3. Save Private Key → mykey.ppk

Command Line (Linux/macOS/WSL) — ใช้ putty-tools

# Install
sudo apt install putty-tools   # Debian/Ubuntu
brew install putty             # macOS

# PPK → OpenSSH (PEM)
puttygen mykey.ppk -O private-openssh -o id_ed25519
puttygen mykey.ppk -O public-openssh -o id_ed25519.pub

# OpenSSH → PPK
puttygen id_ed25519 -O private -o mykey.ppk

การใช้งาน PPK กับเครื่องมือยอดนิยม

Toolรองรับ PPKวิธีใช้
PuTTY✅ NativeConnection → SSH → Auth → Credentials → Private key file: .ppk
WinSCP✅ NativeLogin Dialog → Advanced → Authentication → Private key file: .ppk
FileZilla✅ Native (SFTP)Edit → Settings → SFTP → Add key file (.ppk) → Auto-convert ถ้าไม่รองรับ
Pageant✅ NativeRun Pageant → Add Key (.ppk) → PuTTY/WinSCP/FileZilla ใช้ Key จาก Agent อัตโนมัติ
OpenSSH (ssh/scp/sftp)❌ ไม่รองรับต้อง Convert เป็น OpenSSH Format ก่อน
Git for Windows❌ ใช้ OpenSSHConvert หรือใช้ `ssh-pageant` Bridge
Ansible / Terraform❌ ใช้ OpenSSHConvert หรือระบุ `ansible_ssh_private_key_file` เป็น OpenSSH Key

Best Practices สำหรับ SSH Key Management

  • ใช้ Ed25519 แทน RSA (เร็วกว่า, Key สั้นกว่า, ปลอดภัยกว่า, มาตรฐานใหม่)
  • Passphrase ทุก Key — ไม่เคยเก็บ Unencrypted Private Key
  • One Key Per Device/Purpose — ไม่ใช้ Key เดียวทุกที่
  • Key Rotation: เปลี่ยน Key ทุก 6-12 เดือน หรือเมื่อสงสัย Compromise
  • Hardware Security Key (YubiKey, Nitrokey) — เก็บ Private Key ใน Hardware (FIDO2/U2F) → `ssh-keygen -t ecdsa-sk` / `ed25519-sk`
  • SSH Certificate Authorities — แทน Static Keys ด้วย Short-lived Certs (Netflix BLESS, HashiCorp Vault, Smallstep)

สรุป

PPK = PuTTY Private Key Format ใช้กับ PuTTY, WinSCP, FileZilla, Pageant บน Windows หากทำงาน Cross-platform (Linux/macOS, CI/CD, Git, Ansible, Terraform) ควร Convert เป็น OpenSSH Format (PEM/PKCS#8) ด้วย PuTTYgen หรือ `puttygen` CLI แนะนำใช้ Ed25519 + Passphrase + Hardware Key / SSH Certificates แทน Static Keys