How to Create an SSH Key for GitHub

Draft Forums Development & IT How to Create an SSH Key for GitHub

Tagged: , , , ,

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #60
    admin
    Keymaster

    Hướng dẫn tạo SSH key cho GitHub

    sudo ssh-keygen -t ed25519 -C "dev@vnadv.com"
    /root/.ssh
    ssh -T git@github.com
    

    Thiế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.

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. Clone Repo: Dùng link SSH (dạng git@github.com:...) để clone dự án về server.
    /root/.ssh
    

    1. 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.pub
    

    Sao 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.com
    

    Nế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/.ssh
    

    https://docs.github.com/en/authentication/connecting-to-github-with-ssh

    • This topic was modified 5 days, 10 hours ago by admin.
    • This topic was modified 5 days, 10 hours ago by admin.
    • This topic was modified 5 days, 10 hours ago by admin.
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.