以下の内容はhttps://uga-box.hatenablog.com/entry/2024/05/10/000000より取得しました。


【Github】複数のGithubアカウントを使いわけるためのGithub認証設定

すでに使っているGithubアカウントとは別のアカウントを作りたくて、その手順を調べた

公開鍵の作成

まずは公開鍵を生成する

~/.ssh に移動しておき、ssh-keygen -t rsaで鍵を作る

途中にid_rsaの名前を聞かれるので id_sub_rsa と入れる

$ cd ~/.ssh
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/(username)/.ssh/id_rsa):id_sub_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

公開鍵をクリップボードにコピー

$ pbcopy < ~/.ssh/id_sub_rsa.pub

Githubのsettings > ssh に移動して貼り付け(名前は認証名がわかればなんでもいい)

Sign in to GitHub · GitHub

アカウントが複数あるので ~/.ssh/config ファイルを作成し、以下のように記載する

Host github.com # メインアカウント
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_rsa  # 元々あったメインアカウント用の鍵
  TCPKeepAlive yes
  IdentitiesOnly yes

Host github.com.sub # もう一つのアカウント
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_sub_rsa # もう一つのアカウントの鍵
  TCPKeepAlive yes
  IdentitiesOnly yes

接続を確認する

$ ssh -T git@github.com
Hi uga! You've successfully authenticated, but GitHub does not provide shell access.
$ ssh -T git@github.com.sub
Hi uga2! You've successfully authenticated, but GitHub does not provide shell access.

sshでクローンする

$ git clone git@github.com.sub:xxxxx/yyyyy.git



以上の内容はhttps://uga-box.hatenablog.com/entry/2024/05/10/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14