Draft › Forums › Development & IT › How to Create an SSH Key for GitHub
- This topic has 0 replies, 1 voice, and was last updated 5 days, 10 hours ago by
admin.
-
AuthorPosts
-
2026-04-11 at 11:53 am #60
admin
KeymasterHướng dẫn tạo SSH key cho GitHub
sudo ssh-keygen -t ed25519 -C "dev@vnadv.com" /root/.ssh ssh -T git@github.comThiết lập SSH trên Ubuntu Server giúp bảo mật hơn và bạn không cần nhập mật khẩu GitHub mỗi khi thao tác.
- Tạo SSH Key: Chạy lệnh
ssh-keygen -t ed25519 -C "email_cua_ban@example.com". Nhấn Enter liên tục để dùng thiết lập mặc định. - Lấy Public Key: Chạy lệnh
cat ~/.ssh/id_ed25519.pub, sau đó bôi đen và Copy đoạn mã hiện ra. - Dán vào GitHub: Vào Settings -> SSH and GPG keys -> New SSH key. Đặt tên và dán mã vào ô Key, rồi nhấn Add.
- Kiểm tra: Chạy
ssh -T git@github.com. Nếu hiện thông báo “Hi [Tên-của-bạn]!” là thành công. - Clone Repo: Dùng link SSH (dạng
git@github.com:...) để clone dự án về server.
/root/.ssh1. Tạo SSH Key
Create SSH Key
Chạy lệnh:
Run command:
ssh-keygen -t ed25519 -C "your_email@example.com"Nhấn Enter liên tục để dùng mặc định.
Press Enter repeatedly to use default settings.
2. Lấy Public Key
Get Public Key
Chạy lệnh:
Run command:
cat ~/.ssh/id_ed25519.pubSao chép toàn bộ đoạn mã hiển thị.
Copy the entire output.
3. Thêm vào GitHub
Add to GitHub
Vào Settings → SSH and GPG keys → New SSH key
Go to Settings → SSH and GPG keys → New SSH key
Dán key vào và nhấn Add.
Paste the key and click Add.
4. Kiểm tra kết nối
Test connection
Chạy lệnh:
Run command:
ssh -T git@github.comNếu hiện: Hi [username]!, là thành công.
If you see: Hi [username]!, it is successful.
5. Clone repository
Clone repository
Dùng link SSH dạng:
Use SSH link format:
git@github.com:username/repo.git
Thư mục SSH
SSH Directory
/root/.sshhttps://docs.github.com/en/authentication/connecting-to-github-with-ssh
- Tạo SSH Key: Chạy lệnh
-
AuthorPosts
- You must be logged in to reply to this topic.