Category Archive Programming

Byphunsanit

GIT: set SSH Client

ไฟล์ ~/.ssh/config เป็นไฟล์ที่เก็บ options ของ SSH Client โดยจะช่วยให้การ SSH ง่ายขึ้นแทนการใช้คำสั่งยาว ๆ เช่น แทนที่จะใช้
ssh [email protected] -p 2222 -i ~/.ssh/id_rsa_dev
ก็ใช้ได้แค่
ssh dev-server

ไฟล์ ~/.ssh/config ถูกสร้างขึ้นมา 2 วิธีหลัก ๆ คือ

  1. โดย Sourcetree (หรือโปรแกรม SSH Client อื่นๆ)
  2. โดยคำสั่ง
    1. cd ~/.ssh
    2. touch config
    3. nano config

เนื้อหาในไฟล์จะเป็นประมาณ

# --- Sourcetree Generated ---
Host github.com
    HostName github.com
    User git
    PreferredAuthentications publickey
    IdentityFile /Users/phunsanit/.ssh/phunsanit@GitHub
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------

โดย IdentityFile จะชี้ไปยัง SSH key ที่ใช้กับ host ที่สร้างไว้ โดย ssh-keygen

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