Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Lệnh & cài đặt Git
  6. Cài đặt kết nối SSH
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Cài đặt kết nối SSH


Thiết lập kết nối SSH (Windows)

Đi đến menu Start > All Programs > Open TortoiseGit và khởi động Putty Key Generator.

Open TortoiseGit items and run Puttygen

Nhấp vào “Generate” và di chuyển con trỏ chuột trong khung màu đỏ cho đến khi thanh tiến trình hoàn tất. Điều này sẽ tạo ngẫu nhiên một khóa.

Until the progress bar reaches the right corner, you move the mouse with the red-framed area

Khi quá trình tạo khóa hoàn tất, bạn sẽ thấy màn hình sau. Nhấp vào “Save private key” và lưu tệp “.ppk”.

Save the ppk file by clicking the "Save private key" button.

Bạn có thể xem lại khóa công khai sau này bằng cách tải tệp “.ppk” vào Putty Key Generator.

Để định cấu hình kết nối SSH khi chúng ta đẩy bằng TortoiseGit, nhấp chuột phải vào TortoiseGit, sau đó chọn “Manage”.

If you click TortoiseGit, the following screen will be displayed. Then, click Manage button

Với “origin” được chọn trong cột từ xa, thêm đường dẫn SSH vào trường URL và thêm đường dẫn tệp “.ppk” mà chúng ta vừa lưu vào trường Putty Key. Nhấp vào “Add New/Save”. Bây giờ, nhánh từ xa origin được liên kết với đường dẫn URL SSH sẽ được thêm vào danh sách nhánh từ xa ở kho lưu trữ này. Nhấn “OK” để hoàn tất.

Assign the ppk file that you just saved to the Putty authentication, and then click Add New/Save button

Thiết lập kết nối SSH (Mac)

Mở terminal ở ứng dụng/tiện ích và thực hiện lệnh sau.

$ ssh-keygen

Bạn sẽ thấy đầu ra sau. Bạn có thể tùy chọn nhập cụm mật khẩu cho cặp khóa RSA đã tạo này.

Tiếp tục bằng cách nhấn enter nếu bạn không muốn đặt cụm mật khẩu.

Generating public/private rsa key pair.
  Enter file in which to save the key (/Users/username/.ssh/id_rsa): <Press Enter key>
  Created directory '/Users/username/.ssh'.
  Enter passphrase (empty for no passphrase): <Input passphrase>
  Enter same passphrase again: <Please enter the same passphrase again>
  Your identification has been saved in /Users/username/.ssh/id_rsa.
  Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
  The key fingerprint is:
  57:15:3c:ca:f2:dc:27:6d:c2:9a:88:d0:70:cf:8d:31 username@username-example-device
  The key's randomart image is:
  +--[ RSA 2048]----+
  |             .o. |
  |             .o  |
  |           ... . |
  |      . . E.o    |
  |       +So.O o . |
  |      . ..+ + = +|
  |       . . . o = |
  |        . . o    |
  |                 |
  +-----------------+

Bạn có thể xem khóa SSH công khai bằng lệnh sau.

$ cat ~/.ssh/id_rsa.pub

Ví dụ đầu ra

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkkJvxyDVh9a+zH1f7ZQq/JEI79dVjDSG
  4RzttQwfK+sgWEr0aAgfnxdxQeDKxIxqI1SwyTY8oCcWzvpORuPqwbc7UWWPcCvbQ3jlEdN
  5jvwKM82hincEWwI3wzcnVg2Mn8dH86b5m6REDzwRgozQ3lqrgwGVlTvkHDFs6H0b/1PSrM
  XGppOP/QXGEVhZ6Hy4m3b1wMjjrbYwmWIeYklgoGHyrldhAaDYc33y7aUcRyFyq5DubtsLn
  2oj4K+1q36iviCHxCOri0FDmn2dzylRCI4S+A2/P7Y7rVfdT+8OWYKCBUs8lfjujghEtejq
  Qmj9ikyGTEAW1zQCN7hVwYdjL hoge@hoge.local

Sao chép và dán khóa này vào cài đặt kho lưu trữ từ xa.

Thiết lập kết nối SSH (Bảng điều khiển)

Thực hiện lệnh sau.

$ ssh-keygen

Bạn sẽ thấy đầu ra sau. Bạn có thể tùy chọn nhập cụm mật khẩu cho cặp khóa RSA đã tạo này. Nhấn enter nếu bạn không muốn đặt cụm mật khẩu.

Generating public/private rsa key pair.
  Enter file in which to save the key (/Users/username/.ssh/id_rsa): <Press Enter key>
  Created directory '/Users/username/.ssh'.
  Enter passphrase (empty for no passphrase): <Input passphrase>
  Enter same passphrase again: <Please enter the same passphrase again>
  Your identification has been saved in /Users/username/.ssh/id_rsa.
  Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
  The key fingerprint is:
  57:15:3c:ca:f2:dc:27:6d:c2:9a:88:d0:70:cf:8d:31 username@username-example-device
  The key's randomart image is:
  +--[ RSA 2048]----+
  |             .o. |
  |             .o  |
  |           ... . |
  |      . . E.o    |
  |       +So.O o . |
  |      . ..+ + = +|
  |       . . . o = |
  |        . . o    |
  |                 |
  +-----------------+

Bạn có thể xem khóa SSH công khai bằng lệnh sau.

$ cat ~/.ssh/id_rsa.pub

Ví dụ đầu ra

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkkJvxyDVh9a+zH1f7ZQq/JEI79dVjDSG
  4RzttQwfK+sgWEr0aAgfnxdxQeDKxIxqI1SwyTY8oCcWzvpORuPqwbc7UWWPcCvbQ3jlEdN
  5jvwKM82hincEWwI3wzcnVg2Mn8dH86b5m6REDzwRgozQ3lqrgwGVlTvkHDFs6H0b/1PSrM
  XGppOP/QXGEVhZ6Hy4m3b1wMjjrbYwmWIeYklgoGHyrldhAaDYc33y7aUcRyFyq5DubtsLn
  2oj4K+1q36iviCHxCOri0FDmn2dzylRCI4S+A2/P7Y7rVfdT+8OWYKCBUs8lfjujghEtejq
  Qmj9ikyGTEAW1zQCN7hVwYdjL hoge@hoge.local

Sao chép và dán khóa này trong cài đặt kho lưu trữ từ xa.

Đăng ký khóa công khai SSH vào Backlog

Đăng nhập vào Backlog bằng tên người dùng tài khoản của bạn có quyền truy cập vào kho lưu trữ Git. Sau khi đăng nhập, nhấp vào “Personal Settings”.

Click "Personal setting"

Nhấp vào “Register SSH public key”.

Click "Register SSH public key"

Dán khóa công khai SSH vào vùng văn bản và nhấp vào “Submit”.

Paste the content of SSH public key and click "Register" button

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life