アカウントの作成と設定
この章では、GitHubアカウントの作成から、セキュリティ設定、認証方法の設定まで行います。
アカウント作成
Section titled “アカウント作成”1. サインアップページにアクセス
Section titled “1. サインアップページにアクセス”https://github.com/signup にアクセスします。
2. 必要情報を入力
Section titled “2. 必要情報を入力”- メールアドレス: 有効なメールアドレス(後で変更可能)
- パスワード: 15文字以上、または8文字以上で数字と小文字を含む
- ユーザー名: 英数字とハイフンのみ(後で変更可能だが、URLに影響)
3. メール認証
Section titled “3. メール認証”登録したメールアドレスに届く確認コードを入力します。
プロフィール設定
Section titled “プロフィール設定”基本プロフィール
Section titled “基本プロフィール”Settings → Profile で設定できます。
| 項目 | 説明 | 推奨 |
|---|---|---|
| Name | 表示名 | 本名またはハンドルネーム |
| Bio | 自己紹介(160文字) | スキル・興味を簡潔に |
| Company | 所属組織 | @組織名 形式で入力可 |
| Location | 所在地 | 任意 |
| Website | 個人サイト等 | ポートフォリオURL等 |
プロフィールREADME
Section titled “プロフィールREADME”ユーザー名と同じ名前のリポジトリを作成し、README.mdを追加すると、プロフィールページに表示されます。
# Hi there 👋
## About Me- 🔭 I'm currently working on ...- 🌱 I'm currently learning ...- 📫 How to reach me: ...
## Skills2要素認証(2FA)の設定
Section titled “2要素認証(2FA)の設定”- Settings → Password and authentication → Two-factor authentication
- Enable two-factor authentication をクリック
- 認証方法を選択
認証方法の選択
Section titled “認証方法の選択”| 方法 | 推奨度 | 説明 |
|---|---|---|
| 認証アプリ | ⭐⭐⭐ | Google Authenticator、1Password等 |
| セキュリティキー | ⭐⭐⭐ | YubiKey等のハードウェアキー |
| SMS | ⭐ | 電話番号宛にコード送信(非推奨) |
リカバリーコードの保存
Section titled “リカバリーコードの保存”2FA設定時に表示されるリカバリーコードは必ず安全な場所に保存してください。
リカバリーコードの保存先例:- パスワードマネージャー(1Password、Bitwarden等)- 暗号化されたノート- 印刷して金庫に保管SSH鍵の登録
Section titled “SSH鍵の登録”SSHを使うと、毎回パスワードを入力せずにGitHubと通信できます。
1. SSH鍵の生成
Section titled “1. SSH鍵の生成”# Ed25519(推奨)ssh-keygen -t ed25519 -C "your_email@example.com"
# RSA(互換性が必要な場合)ssh-keygen -t rsa -b 4096 -C "your_email@example.com"パスフレーズを設定することを推奨します。
2. SSH公開鍵をコピー
Section titled “2. SSH公開鍵をコピー”# macOSpbcopy < ~/.ssh/id_ed25519.pub
# Windows (PowerShell)Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard
# Linuxcat ~/.ssh/id_ed25519.pub | xclip -selection clipboard3. GitHubに登録
Section titled “3. GitHubに登録”- Settings → SSH and GPG keys → New SSH key
- Title:
MacBook Pro 2024のように識別しやすい名前 - Key: コピーした公開鍵を貼り付け
- Add SSH key をクリック
4. 接続テスト
Section titled “4. 接続テスト”ssh -T git@github.com# Hi username! You've successfully authenticated...複数のSSH鍵を使い分ける
`~/.ssh/config` で設定できます:# 個人アカウントHost github.com HostName github.com User git IdentityFile ~/.ssh/id_ed25519_personal
# 会社アカウントHost github-work HostName github.com User git IdentityFile ~/.ssh/id_ed25519_work使用時: git clone git@github-work:company/repo.git
GPG署名の設定
Section titled “GPG署名の設定”コミットに署名を付けることで、本人が作成したことを証明できます。
1. GPG鍵の生成
Section titled “1. GPG鍵の生成”# GPGがインストールされていない場合# macOS: brew install gnupg# Ubuntu: sudo apt install gnupg
gpg --full-generate-key選択肢:
- 鍵の種類: RSA and RSA(デフォルト)
- 鍵長: 4096
- 有効期限: 1年〜2年を推奨
- 名前・メール: GitHubアカウントと同じメールアドレス
2. 鍵IDを確認
Section titled “2. 鍵IDを確認”gpg --list-secret-keys --keyid-format=long# sec rsa4096/3AA5C34371567BD2 2024-01-01 [SC]# ↑ この部分が鍵ID3. 公開鍵をエクスポート
Section titled “3. 公開鍵をエクスポート”gpg --armor --export 3AA5C34371567BD24. GitHubに登録
Section titled “4. GitHubに登録”- Settings → SSH and GPG keys → New GPG key
-----BEGIN PGP PUBLIC KEY BLOCK-----から-----END PGP PUBLIC KEY BLOCK-----までを貼り付け
5. Gitの設定
Section titled “5. Gitの設定”git config --global user.signingkey 3AA5C34371567BD2git config --global commit.gpgsign true署名付きコミットには「Verified」バッジが表示されます。
個人アクセストークン(PAT)の管理
Section titled “個人アクセストークン(PAT)の管理”HTTPS経由でGitHubにアクセスする場合、パスワードの代わりにPATを使用します。
Fine-grained tokens(推奨)
Section titled “Fine-grained tokens(推奨)”より細かい権限制御が可能な新しい形式のトークンです。
- Settings → Developer settings → Personal access tokens → Fine-grained tokens
- Generate new token
- 設定項目:
| 項目 | 説明 |
|---|---|
| Token name | 用途がわかる名前 |
| Expiration | 有効期限(90日以内推奨) |
| Repository access | アクセス可能なリポジトリを限定 |
| Permissions | 必要最小限の権限のみ付与 |
Classic tokens
Section titled “Classic tokens”従来形式のトークン。広範囲のアクセスが必要な場合に使用。
よく使うスコープ:- repo: プライベートリポジトリへのフルアクセス- workflow: GitHub Actionsワークフローの更新- read:org: 組織情報の読み取り中級者向けTips
Section titled “中級者向けTips”ssh-agentでパスフレーズ入力を省略
Section titled “ssh-agentでパスフレーズ入力を省略”# macOS - キーチェーンに保存ssh-add --apple-use-keychain ~/.ssh/id_ed25519
# Linux - ssh-agentを起動eval "$(ssh-agent -s)"ssh-add ~/.ssh/id_ed255191Password SSH Agent
Section titled “1Password SSH Agent”1Passwordを使っている場合、SSH鍵を1Password内で管理し、生体認証で使用できます。
GitHub CLI での認証
Section titled “GitHub CLI での認証”# インタラクティブに認証gh auth login
# トークンで認証gh auth login --with-token < token.txt
# 認証状態の確認gh auth status| 設定項目 | 優先度 | 状態確認場所 |
|---|---|---|
| 2要素認証 | 必須 | Settings → Password and authentication |
| SSH鍵 | 推奨 | Settings → SSH and GPG keys |
| GPG署名 | 任意 | Settings → SSH and GPG keys |
| PAT | 必要に応じて | Settings → Developer settings |
次の章では、リポジトリの作成と基本操作を学びます。
Q1. GitHubアカウント作成時のパスワード要件として正しいものはどれですか?
Q2. 2要素認証(2FA)の認証方法として最も推奨されるものはどれですか?
Q3. SSH鍵でGitHubに接続する主なメリットはどれですか?