ตั้งค่า Git System บน Ubuntu 24+

Ubuntu 24+ by Keptcode.com

Last Updated: 2024-08-27 00:30

ตั้งค่า อีเมล์ & ชื่อ ที่ใช้งาน Git System

Path: [skeleton]

Terminal

# แสดง Config ทั้งหมด
$ git config --list

# Config อีเมล์ & ชื่อ ที่เราใช้งาน git อยู่
$ git config --global user.email "demo@email.com"
$ git config --global user.name "Keptcode"

สร้าง Access Key สำหรับเชื่อม Github, Gitlab, Bitbucket

Path: [skeleton]

Terminal

# สร้าง RSA Key ขึ้นมา สามารถใส่รหัสผ่าน 2 ชั้นได้ (ถ้าไม่ต้องการปล่อยว่างได้)
$ sudo ssh-keygen -t rsa -f ~/.ssh/ubuntu24-keptcode-instance-01-rsa-key

# เพิ่ม RSA Key ใหม่
$ sudo ps -e | grep [s]sh-agent
$ ssh-agent /bin/bash && ssh-add ~/.ssh/ubuntu24-keptcode-instance-01-rsa-key

# แสดง Private Key (RSA Key)
cat ~/.ssh/ubuntu24-keptcode-instance-01-rsa-key

# แสดง Public Key (RSA Key)
cat ~/.ssh/ubuntu24-keptcode-instance-01-rsa-key.pub

ตั้งค่า SSH สำหรับ bitbucket.org

Path: [skeleton]

Terminal

# แก้ไข SSH 
$ sudo nano ~/.ssh/config

# เพิ่มคำสั่งเหล่านี้ลงไป
Host bitbucket.org
  HostName bitbucket.org
  User git
  IdentityFile ~/.ssh/ubuntu24-keptcode-instance-01-rsa-key
  UserKnownHostsFile ~/.ssh/known_hosts
  ForwardAgent yes

# Reload SSH ใหม่
sudo systemctl reload ssh && sudo systemctl status ssh

# สามารถนำ Public Key (RSA Key) นี้ไปเพิ่มใน bitbucket ได้เลย
cat ~/.ssh/ubuntu24-keptcode-instance-01-rsa-key.pub