GitHub + SSH で複数アカウント切替え

Git HTTPS Credential Helper がややこしいので SSH に切り替える。

GitHub リポジトリを指す remote origin の変更が必要となりますので、ざっくり概要を見ておきます。


# HTTPS 利用していたとする
git remote -v
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)

# SSH 形式の URL に変更
git remote set-url origin [email protected]:OWNER/REPOSITORY.git

# 確認
git remote -v
# Verify new remote URL
> origin [email protected]:OWNER/REPOSITORY.git (fetch)
> origin [email protected]:OWNER/REPOSITORY.git (push)

👉 リモートリポジトリを管理する - GitHub Docs

🧑🏻‍💻 手順

1. 鍵をPC側で作成。


❯ ssh-keygen -t ed25519 -C [email protected] -f ~/.ssh/id_ed25519_main

👉 新しい SSH キーを生成して ssh-agent に追加する - GitHub Docs

2. GitHub にログインして貼る。Authentication keys


❯ pbcopy < ~/.ssh/id_ed25519_main.pub

👉 SSH and GPG keys - GitHub

3. ~/.ssh/config を設定する。


❯ vi ~/.ssh/config

Host github-main
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_ed25519_main
  TCPKeepAlive yes
  IdentitiesOnly yes # need for multiple accounts

Host github-sub
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_ed25519_sub
  TCPKeepAlive yes
  IdentitiesOnly yes # need for multiple accounts

4. PC側プロジェクト内で remote origin を書き換える。


git@github-main:your-main/Sample.git


❯ git remote -v
origin https://github.com/your-main/Sample.git (fetch)
origin https://github.com/your-main/Sample.git (push)

❯ git remote set-url origin git@github-main:your-main/Sample.git

❯ git remote -v
origin git@github-main:your-main/Sample.git (fetch)
origin git@github-main:your-main/Sample.git  (push)

❯ cat .git/config
[remote "origin"]
url = git@github-main:your-main/Sample.git
fetch = +refs/heads/*:refs/remotes/origin/*

5. 接続を確認する。


❯ ssh -T git@github-main
Hi your-main! You've successfully authenticated, but GitHub does not provide shell access.

👉 [備忘] 複数Githubアカウントでssh接続設定(config)を使い分ける手順 #GitHub - Qiita

 

🧑🏻‍💻 まとめ

URL 記述部分は、ssh:// がついてるほうが意味が分かりやすい気がします。

その場合は ~/.ssh/config の port 22 の記述は不要のようですが、

現在 GitHub ではスキーマ部分消えています。

などとダラダラ書きましたが、以下読んでみるとよく分かります。

👉 Multiple GitHub Accounts & SSH Config - Stack Overflow
👉 Using multiple github accounts with ssh keys
👉 【Git】Obsidian を GitHub と連携する
👉 初心者向け Git コマンドと領域の移動をシーケンス図で書いてみた


【Apple】iPhone に着信する SMS のメッセージを Mac で受ける

2FA などいちいち iPhone を手にとって見るのが面倒すぎる。

iPhone 側の


[設定] - [アプリ] - [メッセージ]

から。

表示される転送先 Mac を ON に。

Apple ID で紐付いてるんだって。


【Android Studio】 エディタからの左のファイル表示(Project View) を同期させる

Android Studio の更新や

プロジェクトの設定時に、

毎回設定しているのですが、

毎回忘れて調べているので。

 

🧑🏻‍💻 以前は「Autoscroll from source」だった

👉 Android Studioでエディタでファイルを表示したらProject Viewでも表示する方法 #AndroidStudio - Qiita

Project View に設定の歯車ボタンがなくなってる!!

 

🧑🏻‍💻 「Always Select Opened File」

いつ変更になったか知らんが、

毎回探すのに苦労しますわ。


Project View
  ↓

右クリック

  ↓

Behavior

  ↓

Always Select Opened File

 

🧑🏻‍💻 まとめ

「shift → shift」 から「always」で調べると早い。

GUI操作の変更は調べづらい。


Let's Encrypt の 有効期限通知メール が中止になる件

メールが来ましたので。

Hi,
As a Let’s Encrypt Subscriber, you benefit from access to free, automated TLS certificates. One way we have supported Subscribers is by sending expiration notification emails when it’s time to renew a certificate.

こんにちは、Let's Encryptサブスクライバーとして、無料の自動TLS証明書へのアクセスの恩恵を受けます。購読者をサポートする方法の1つは、証明書を更新するときに有効期限通知メールを送信することです。

We’re writing to inform you that we intend to discontinue sending expiration notification emails. You can learn more in this blog post. You will receive this reminder email again in the coming months:

有効期限通知メールの送信を中止することをお知らせします。このブログ記事で詳細を知ることができます。今後数か月以内に、このリマインダーメールが再び届きます。

https://letsencrypt.org/2025/01/22/Ending-Expiration-Emails

Here are some actions you can take today:

今日実行できるアクションをいくつか紹介します。

Automate with an ACME Client that supports Automated Renewal Information (ARI). ARI enables us to automatically renew your certificates ahead of schedule should the need arise:

自動更新情報 (ARI) をサポートする ACME クライアントで自動化します。ARIを使用すると、必要が発生した場合、予定より早く証明書を自動的に更新できます。

https://letsencrypt.org/2024/04/25/guide-to-integrating-ari-into-existing-acme-clients

Sign up for a third-party monitoring service that may provide expiration emails. We can recommend Red Sift Certificates Lite, which provides free expiration emails for up to 250 active certificates:

有効期限のメールを提供する可能性のあるサードパーティの監視サービスにサインアップしてください。最大 250 の有効な証明書に無料の有効期限メールを提供する Red Sift Certificates Lite をお勧めします。

https://redsift.com/pulse-platform/certificates-lite

Opt in to emails. While we are deprecating expiration notification emails, you can opt in to continue to receive other emails. We’ll keep you informed about technical updates, and other news about Let’s Encrypt and our parent nonprofit, ISRG, based on the preferences you choose:

メールにオプトインする。有効期限通知メールは非推奨ですが、他のメールの受信を継続することをオプトインできます。Let's Encryptと親会社であるISRGに関する技術的な最新情報やその他のニュースについては、選択した好みに基づいてお知らせします。

https://letsencrypt.org/opt-in/

All the best,
Let’s Encrypt

 

🤔 まとめ

更新期限通知メール送信にもお金がかかる。

更新後、期限は分かるので、特に気にしなくていいようにも思う。


【Chrome】Markdown (.md) ファイルを簡単にブラウザで見る方法

.md のファイルがドキュメントとして送られてきました。

どうやってみますか。

 

🧑🏻‍💻 Markdown Viewer

プラウザが Chrome だとしたらこれでいいでしょう。

軽量で簡単。

👉 Markdown Viewer - Chrome ウェブストア

オープンソースなので安心です。

👉 simov/markdown-viewer: Markdown Viewer / Browser Extension

 

🧑🏻‍💻 Markdown Viewer の使い方

エクステンションをインストールしたら、

エクステンションの詳細設定から2箇所を許可する。

あとは、

右クリックから Chrome で開く、か

Chrome 上にドラッグしてドロップする

だけです。

Mermaid も表示できます。

特に編集の必要のないときは、

これでサクッと見れるのでよいです。

👉 AndroidStudioでMarkdownプレビューが表示されない時の対処法