カテゴリ
タグ
Agent Mode Astro Auto Approve changelog Chat clear CLI Code Actions Codex compact context Copilot copy Ctrl+S CUDA Cursor delegate diff experimental FAQPage Gemini git GitHub GitHub Copilot Google Google Search Console init Linux Mac model NES NoAdapterInstalled Node.js nvm OpenAI params plan PowerShell prompt props Python research rewind SEO share Shift+Tab SSH SSH config ssh-copy-id streamer-mode undo usage Visual Studio VS Code VS2026 Windows WSL アップデート インストール エディター エラー対応 エラー解決 コンテキスト コンポーネント設計 シェル実行 ショートカット プチキャンプ メンション モード切替 リダイレクト リネーム 一覧 公開鍵認証 動的ルーティング 天体観測 奈良県 学生 岩手県 市ケ原 日帰り旅行 日本語 明けの明星 曽爾高原 構造化データ 流星群 温泉 神戸ハイキング 自動化 自動承認 設定 設定方法 静的サイト
314 文字
2 分
Windows で ssh-copy-idを使う方法【WSL】
はじめに
Windowsからsshの公開鍵をサーバーに転送するのを手作業でやっていませんか?Windowsの PowerShell で ssh-copy-id を使いたくないですか? 本記事では Windowsで手軽に ssh-copy-id を使用する方法 を解説します。 WSLを利用します。
前提条件
- WindowsにWSLがインストールされている
- 接続先サーバーに
ssh user@hostで到達できる
手順
1. WSLを起動する
wsl以降はWSL内で実行します。
2. SSH鍵を用意する
mkdir -p ~/.ssh
chmod 700 ~/.ssh新規作成する場合
ssh-keygen -t ed25519 -f ~/.ssh/key- 秘密鍵:
~/.ssh/key - 公開鍵:
~/.ssh/key.pub
Windowsで作成済みの鍵を使う場合
Windows側の鍵をWSLにコピーします。
cp /mnt/c/Users/ユーザー名/.ssh/id_ed25519 ~/.ssh/key
cp /mnt/c/Users/ユーザー名/.ssh/id_ed25519.pub ~/.ssh/key.pub
chmod 600 ~/.ssh/key
/mnt/c/Users/ユーザー名/はWindows側のホームディレクトリです。鍵のファイル名は環境に合わせて変更してください。
3. 公開鍵をサーバーに登録する
ssh-copy-id -i ~/.ssh/key.pub user@host初回はパスワード入力が必要です。
4. 接続を確認する
ssh -i ~/.ssh/key user@hostパスワードなしで接続できれば完了です。
関連記事
毎回
-iオプションを省略したい場合は、SSH configを設定してください。
SSH configを設定する方法
Windows で ssh-copy-idを使う方法【WSL】
https://naonao-na.com/posts/ssh-copy-id-windows/
