1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘録】Raspberry Pi 5 で GitHub に一時的に SSH接続する方法(履歴を残さず安全に運用)

Last updated at Posted at 2025-06-13

📝 はじめに

こんにちは、piyovateです!
Raspberry Pi 5 を使って GitHub に一時的に接続したいとき、

  • Git のユーザー情報や履歴を残したくない
  • 作業後に SSH 鍵や設定をすべて消したい
  • 一時的に clone/push だけできればいい

という用途に向けた ミニマルかつセキュアな Git 設定手順を紹介します。完全な備忘録スタイルです。


✅ 1. Git のインストールと仮ユーザー設定

sudo apt update
sudo apt install git -y

Git で commit するには、ユーザー名とメールの設定が必要です。設定していないと以下のようなエラーが出ます:

Author identity unknown
*** Please tell me who you are.
fatal: unable to auto-detect email address

以下のように設定して回避します:

git config --global user.name "Temporary User"
git config --global user.email "temp@example.com"

プロジェクト単位でのみ設定したい場合:

cd your-project
git config user.name "Temporary User"
git config user.email "temp@example.com"

🔐 2. SSH鍵の作成(パスワード付き)

ssh-keygen -t ed25519 -C "temp@example.com"

以下のように入力してパスワード(パスフレーズ)を設定します:

Enter file in which to save the key (/home/pi/.ssh/id_ed25519): [Enter]
Enter passphrase (empty for no passphrase): ********
Enter same passphrase again: ********

🔗 3. GitHub に鍵を登録

cat ~/.ssh/id_ed25519.pub

上記コマンドで表示される公開鍵をコピーし、
GitHub → [Settings] → [SSH and GPG keys] → [New SSH key] にペーストして登録。


✅ 4. 接続確認

ssh -T git@github.com

以下のように表示されれば接続成功です:

Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.

🚀 5. リポジトリ操作(clone / push)

既存のリポジトリを clone:

git clone git@github.com:yourname/your-repo.git

新規作成して push(必要に応じて):

mkdir test-repo && cd test-repo
git init
touch README.md
git add .
git commit -m "initial commit"
git remote add origin git@github.com:yourname/test-repo.git
git push -u origin master

🧹 6. 作業後の削除(痕跡を残さない)

削除対象 コマンド・操作
GitHub 上の鍵 GitHub → Settings → SSH Keys → 削除
ローカル SSH 鍵 rm ~/.ssh/id_ed25519*
Git設定の削除 git config --global --unset user.name
git config --global --unset user.email

📌 おわりに

最低限の設定で GitHub に一時的に接続し、作業後はすべて削除して安全に終える運用フローでした。
ちょっとした検証や一時的な clone/push に便利です。

やってることは通常通りですが、久しぶりに git の初期設定をしたのでまとめておきました。
誰かのお助けになれれば幸いです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?