LoginSignup
1
1

More than 1 year has passed since last update.

ssh接続でgit pullやpushでのパスワード入力を省略したい

Posted at

はじめに

VsCodeからSSH経由でGitに接続。
git pullやpushでの毎回のパスワード入力を省略したくて試行した内容メモです。

本文

まずsshキーをssh-agentへ登録。

$ ssh-add /Users/user_name/.ssh/id_rsa

と思ったら失敗。communication with agent failedとのこと。
エージェントとの通信に失敗しました、つまりエージェントが起動してないってことでした。

Could not add identity "/home/webuser/.ssh/id_rsa": communication with agent failed

よってssh-agentを起動するコマンドを実施後に、ssh-addを再チャレンジ。
(ssh-agent -> sshの公開鍵認証を代行してくれる)

$ eval `ssh-agent`
$ ssh-add /Users/user_name/.ssh/id_rsa

成功! ssh-add -lでキーの登録を確認できました。

しかしOSの再起動後にまたパスワードの要求が、、、
前回確認できたキーの登録も無し。

error fetching identities for protocol 1: communication with agent failed
error fetching identities for protocol 2: communication with agent failed
The agent has no identities.

どうやらシェルの再起動でssh-agentの情報はリセットされるらしい。

WindowsのPowerShellを管理者権限で起動し、ssh-agentの自動起動を設定してみる。

Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent

上記コマンド実行後、再起動してもパスワードの入力を要求されなくなりました!

参考にさせていただいた記事
https://qiita.com/sshojiro/items/60982f06c1a0ba88c160
https://qiita.com/aisha/items/807fd2693dea77b1c695
https://qiita.com/fuji44/items/da63086c11c772c9f5fb

1
1
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
1