Skip to content

PlusMagi's Blog By Pitt Phunsanit

Plus emotional magic to the knowledge of logic.

  • หน้าแรก
  • About’s Pitt
Close Button

SSH: ให้ mac จำ login with passphrasSSH: ให้ mac จำ login with passphras

2021-02-062021-02-06| phunsanitphunsanit| 0 Comment | 00:00

เป็นขั้นตอนสุดท้ายในการย่อคำสั่ง SSH แล้วคือแทนที่จะมากรอก passphras เราก็ใช้ MacOs (และ all apple device) กรอก login passphras แทนเรา เมื่อเราเรียก ใช้คำสั่ง อย่าง ssh digitalocean_vps มันจะมีคำถามอยู่ว่า Enter passphrase for key ‘/Users/phunsanit/.ssh/digitalocean_vps‘: คือยังต้องกรอก passphras ให้อยู่นั่นละ แต่อยากจะใช้แค่ ssh digitalocean_vps ก็เข้าไปใน server ได้เลย ก็ทำได้โดยใช้ password manager ของ MacOS Keychain Access (หรือ “การเข้าถึงพวงกุญแจ”)


ทำให้ mac ใช้ ssh-agent ให้เองอัตโนมัติ (ทำครั้งเดียว) Set and Forget

  1. เปิดไฟล์ Config โดยคำสั่ง
    nano ~/.ssh/config
  2. เพิ่มไว้ บนสุด ของไฟล์
    Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_rsa
  3. บันทึก
  4. ปิด Terminal แล้วเปิดใหม่ (New Window)

โดย
AddKeysToAgent yes: เมื่อคุณ SSH ครั้งแรกและใส่รหัสผ่าน มันจะจำกุญแจนั้นลง Agent ให้อัตโนมัติ (ไม่ต้องสั่ง ssh-add เอง)
UseKeychain yes: สำคัญมาก! มันสั่งให้ SSH ไปดึงรหัส Passphrase จาก Apple Keychain (ที่คุณเพิ่งบันทึกไป) มากรอกให้เอง


manual add Apple Keychain

  1. add โดยคำสั่งรูปแบบ
    ssh-add --apple-use-keychain ~/.ssh/{key no .pub}
    เช่น
    ssh-add --apple-use-keychain ~/.ssh/digitalocean_vps
  2. ตั้งสิทธิ์ไฟล์
    chmod 600 ~/.ssh/digitalocean_vps
  3. ทดสอบโดยการใช้
    ssh digtalocean_vps

ดู passphras ที่เก็บเอาไว้

  1. เปิดโปรแกรม Keychain Access
    1. กด Command + Spacebar (เพื่อเปิด Spotlight Search)
    2. พิมพ์ว่า Keychain Access (หรือ “การเข้าถึงพวงกุญแจ”) แล้วกด Enter
    3. ในช่องค้นหา (มุมขวาบนของโปรแกรม) ให้พิมพ์ชื่อไฟล์กุญแจของคุณ เช่น digitalocean_vps
    4. จะเห็นรายการประมาณว่า SH: /Users/phunsanit/.ssh/digitalocean_vps
  2. กดดูรหัส
    1. ดับเบิ้ลคลิก ที่รายการนั้น
    2. ติ๊ก “Show password” (แสดงรหัสผ่าน)
    3. กรอก รหัสผ่านเข้า mac ของเรา
    4. จะเห็น passphras ที่ safe อยู่

อ่านเพิ่มเติม

  • SSH: ช่วยจำ host โดย .ssh\config
  • SSH: login with passphrase
  • Keyboard Shortcuts (คีย์ลัด) ใน Terminal
  • Command Chaining เชื่อมคำสั่ง
Read MoreRead More

Posts pagination

ก่อนหน้า 1 … 290 291 292 … 904 ถัดไป

Projects

  • Statement columns mapping Helper
  • PlusMagi Site Search
  • jQuery Plus Repeater

Recent Posts

  • MariaDB: เช็ค Character Set และ Collation
  • MariaDB: การแปลง Encoding
  • WordPress: แก้ Double / Triple Escaping
  • MariaDB: Character Set และ Collation
  • WinGet: การติดตั้ง TortoiseSVN

Archives

Categories

  • AI (10)
  • Businesses (3)
  • Design (31)
    • UX/UI (3)
  • Histories (8)
  • Life (51)
    • Books (23)
      • สืบสวน (4)
    • ECO (3)
    • Sci-Fi (2)
    • พุทธ (4)
  • Network (294)
    • Android (13)
      • F-Droid (7)
    • Apache Apache HTTP Server (17)
    • Docker (28)
    • Homebrew (14)
    • IIS (7)
    • IOT (4)
    • Linux (92)
    • macOS (68)
      • OrbStack (10)
    • Nginx (26)
    • RabbitMQ (4)
    • Samba (5)
    • Shell Script (28)
    • SSH (11)
    • Windows (103)
      • PowerShell (22)
      • WinGet (10)
      • WSL (21)
  • Programming (619)
    • API (19)
      • REST (5)
      • Swagger (6)
    • C# (15)
      • .NET Core EF (3)
    • CI/CD (7)
    • Database (166)
      • DBeaver (3)
      • RDBMS (148)
        • DB2 (2)
        • MariaDB (22)
        • MySql (60)
        • Oracle Database (4)
          • 10g (2)
        • PostgreSQL (3)
        • SQL Server (83)
          • ADS (3)
          • SMO (4)
          • SSMS (8)
          • T-SQL (26)
    • Flutter (2)
    • GIT (23)
    • Java (44)
      • JasperReports (3)
      • Joget (19)
      • Spring Boot (14)
    • Node.js (1)
    • PowerBuilder (11)
      • PowerBuilder 8 (10)
    • Python (8)
    • Rust (1)
    • SVN (1)
    • Testing (7)
      • Automated Testing (4)
        • Playwright (2)
        • Selenium (2)
    • UML (1)
    • Version Control (1)
    • Web (286)
      • CSS (16)
        • Bootstrap (3)
        • Tailwind CSS (3)
      • HTML (23)
      • JavaScript (108)
        • AG Grid (1)
        • Angular (1)
        • jQuery (64)
          • DataTables (14)
        • React (2)
        • Tabulator (11)
        • TypeScript (10)
        • Vue.js (3)
      • PHP (166)
        • CodeIgniter (11)
        • Laravel (33)
          • Laravel 11 (10)
          • Laravel 5 (19)
        • PrestaShop (1)
        • Yii (19)
          • Yii 2 (16)
      • SEO (2)
      • WordPress (22)
  • Programs (84)
    • Bitwarden (5)
    • Excel (8)
    • Figma (7)
    • Google Chrome (6)
    • Mozilla Firefox (9)
    • Oh My ZSH (4)
    • Stalwart (5)
    • USB Boot (7)
  • Q & A (8)
  • Security (36)
  • Tips & Tricks (72)
    • iPhone (7)
      • Jailbreaking (2)
  • กฎหมาย (6)
  • คณิตศาสตร์ (4)

Sirat WordPress Theme By VWThemes

Scroll Up