{"id":16672586,"url":"https://github.com/hankei6km/vscode-remote-forwarder","last_synced_at":"2025-09-20T21:33:49.094Z","repository":{"id":151375009,"uuid":"189260158","full_name":"hankei6km/vscode-remote-forwarder","owner":"hankei6km","description":"Visual Studio Code の Remote Development において、Remote - SSH から Docker コンテナへ接続するための補助的なシェルスクリプト","archived":false,"fork":false,"pushed_at":"2019-08-23T11:14:44.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-19T18:37:39.518Z","etag":null,"topics":["containers","remote","ssh","visual-studio-code"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hankei6km.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-29T16:19:00.000Z","updated_at":"2019-08-23T11:14:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"941dee88-bfc4-4457-974c-6432c3365051","html_url":"https://github.com/hankei6km/vscode-remote-forwarder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankei6km%2Fvscode-remote-forwarder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankei6km%2Fvscode-remote-forwarder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankei6km%2Fvscode-remote-forwarder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankei6km%2Fvscode-remote-forwarder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hankei6km","download_url":"https://codeload.github.com/hankei6km/vscode-remote-forwarder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243320756,"owners_count":20272560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","remote","ssh","visual-studio-code"],"created_at":"2024-10-12T12:06:44.255Z","updated_at":"2025-09-20T21:33:44.022Z","avatar_url":"https://github.com/hankei6km.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vscode-remote-forwarder\n\nVisual Studio Code の Remote Development において、Remote - SSH から Docker コンテナへ接続するための補助的なシェルスクリプト.\n\n    Visual Studio Code\n       `- Remote SSH\n             |\n          SSH Host\n             `- remote-forwarder\n                     `- Docker\n                          |-\u003e Container1 (Go)\n                          |-\u003e Container2 (Python)\n                          .\n                          .\n\n## Requirements\n\n- SSH Host: `requester.sh` から `docker exec` を実行する権限. シェルクリプトを実行するためのコマンド(`socat` `sem`等).\n- 各コンテナ: Visual Studio Code のリモートサーバーをインストールし実行ができる環境(Debian stretch slim ベースのイメージならば、wget と procps パッケージが必要).\n\n## Installation\n\n以下、SSH Host 上で実施.\n\n- ディレクトリを作成し、`requester.sh` `forwarder.sh` を配置.\n- `authorized_keys` へ鍵を登録するときに、以下のように `command` を指定(`'${HOME}/.bash_profile'` `/path/to` `USER` `CONTAINER` は環境に合わせて変更).\n\n``` text\ncommand=\"/path/to/requester.sh -s '${HOME}/.forwarder_env' -u USER CONTAINER \\\"${SSH_ORIGINAL_COMMAND}\\\"\" ssh-....\n```\n\nコンテナ内では、`-u` で指定したユーザーで Visual Studio Code のリモートサーバーが実行されます.\n\n`-s` で指定されたファイルは、コンテナ内で Visual Studio Code のリモートサーバーが実行されるときにインポート(`source`)されます. サーバーのインスタンスへ環境変数(例.`GOPATH`等)を与えることを想定しています\n(インポートされるファイルはコンテナ内に配置します. またファイル名の展開もコンテナ内で実施されます).\n\n## Usage\n\n- 接続先のコンテナを実行しておく.\n- SSH Host 上で `forwarder.sh` を実行しておく.\n- Visual Studio Code から、`authorized_keys` の設定を行った鍵で SSH Host へ接続.\n\n## Tips\n\n### １つの鍵で複数のコンテナへ接続する\n\n前提.\n\n- SSH Host は Client からの `REMOTE_VSCODE_SEND*` 環境変数を受け付けるようにできる.\n- 接続されるコンテナの名前を `vscode-remote-` で始まるようにできる.\n\nSSH Host上での設定.\n\n- SSH Host の設定で、クライアントからの環境変数 `REMOTE_VSCODE_SEND` を受け付けるようにする(`sshd_config` の`Match` ルールで `AcceptEnv REMOTE_VSCODE_SEND*` を指定する等).\n- `authorized_keys` の記述を以下のように変更する.\n\n``` text\ncommand=\"CONTAINER=\\\"\\\"; for v in \\\"${!REMOTE_VSCODE_SEND@}\\\" ; do CONTAINER=\\\"${CONTAINER}${!v}\\\" ; done ; /path/to/requester.sh  -s '${HOME}/.forwarder_env' -u 1000 vscode-remote-\\\"${CONTAINER}\\\" \\\"${SSH_ORIGINAL_COMMAND}\\\"\" ssh-...\n```\n\nクライアントPC上での設定.\n\n- `REMOTE_VSCODE_SEND0=golang` `REMOTE_VSCODE_SEND1=extension` のようにコンテナ名の末尾を環境変数に設定(Visual Studio Code内でのみ利用なら`terminal.integrated.env.windows` 等で指定).\n- `.ssh/config` へ以下のようにコンテナ毎の接続設定を作成.\n\n      Host container-golang\n          HostName foo\n          User bar\n          IdentityFile C:\\Users\\bar\\.ssh\\vscode-remote\n          SendEnv REMOTE_VSCODE_SEND0\n          .\n          .\n      Host container-extension\n          HostName foo\n          User bar\n          IdentityFile C:\\Users\\bar\\.ssh\\vscode-remote\n          SendEnv REMOTE_VSCODE_SEND1\n\n以上の設定で、Visual Stuido Code の Host Explorer 等から `container-*` へ接続すると、`bar@foo` (`C:\\Users\\bar\\.ssh\\vscode-remote` 鍵を利用)への接続を経由し、それぞれのコンテナへ接続されるようになる.\n\n## License\n\nCopyright (c) 2019 hankei6km\n\nLicensed under the MIT License. See LICENSE in the project root.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhankei6km%2Fvscode-remote-forwarder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhankei6km%2Fvscode-remote-forwarder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhankei6km%2Fvscode-remote-forwarder/lists"}