ไฟล์ ~/.ssh/config เป็นไฟล์ที่เก็บ options ของ SSH Client โดยจะช่วยให้การ SSH ง่ายขึ้นแทนการใช้คำสั่งยาว ๆ เช่น แทนที่จะใช้ssh [email protected] -p 2222 -i ~/.ssh/id_rsa_dev
ก็ใช้ได้แค่ssh dev-server
ไฟล์ ~/.ssh/config ถูกสร้างขึ้นมา 2 วิธีหลัก ๆ คือ
- โดย Sourcetree (หรือโปรแกรม SSH Client อื่นๆ)
- โดยคำสั่ง
cd ~/.sshtouch confignano 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
อ่านเพิ่มเติม