LoginSignup
1
1

More than 1 year has passed since last update.

VSCode Dev Containerでssh-addがnot found

Posted at

やりたかったこと

VSCode Dev ContainerでGitリポジトリを操作するため、SSH接続を使用したい。

参考にした記事はこちら。

問題

ssh-agentで秘密鍵を登録して、いざContainer上で確認すると「ssh-add: not found」に・・・

# ssh-add -l
/bin/ash: ssh-add: not found

原因

どうやらopensshが必要らしい。使っていたのはAlpineイメージで、opensshが入っていなかった。

解決

Dev Containerを使う時に必要なのでpostCreateCommandopnesshをインストール。

.devcontainer/devcontainer.json
{
    "postCreateCommand": "apk update && apk add -U --no-cache openssh"
}

rebuildすると無事に登録した秘密鍵が認識されていた。

# ssh-add -l
3072 SHA256:**************** *****@example.com (RSA)

最終的にはopensshと一緒にgitもインストールして、無事Container上でGitリポジトリを扱えるようになった。

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